[Qt-interest] Problem about QFileDialog::getOpenFileName() style
Steven Doerfler
sgd-qt at lugaru.com
Thu Feb 25 18:00:36 CET 2010
On 2/24/2010 8:05 PM, 程梁 wrote:
> 2010/2/25 Steven Doerfler <sgd-qt at lugaru.com <mailto:sgd-qt at lugaru.com>>
>
> On 2/24/2010 5:57 AM, Oliver.Knoll at comit.ch
> <mailto:Oliver.Knoll at comit.ch> wrote:
>> ?? wrote on Wednesday, February 24, 2010 10:25 AM:
>>
>>> ...
>>> I use QFileDialog::getOpenFileName() to open a file chooser. I read
>>> the document that this static function will invoke native dialog on
>>> Windows. I run it on Windows XP, but the style of this dialog is not
>>> XP theme. It is just like Windows 98.
>>>
>> Hmmm, you are right: in my application I do get the "native" dialog (with the "Last used", "Desktop" etc. icons on the left), but it indeed looks a bit different (really more like the "Windows 2000 look") than the "File open" dialog I get from the Notepad application for example, see attached screenshot. And the rest of my application *does* "look like Windows XP" (so I am using the Windows XP Qt style).
>>
>
> I think Windows programs get the old style of dialog unless they
> use a manifest to specify that they want version 6 of the common
> controls, not the default of version 5.
>
> For instance, say your program is named example.exe. Create a
> simple XML file named example.com.manifest in the same directory
> with contents as shown here
> <http://msdn.microsoft.com/en-us/library/wwtazz9d%28VS.71%29.aspx>.
> Then your program should get the newer style of dialog.
>
> You can also embed the manifest data in an .exe file using the
> Windows SDK tool mt.exe
> <http://msdn.microsoft.com/en-us/library/aa375649%28VS.85%29.aspx>
> but watch out for a bug in some mt.exe versions
> <http://support.microsoft.com/Default.aspx?kbid=921337>.
>
> Steven
>
>
> Thank you for metion this. I did as Steven said but it didn't work. I
> simply put manifest file in the same directory with exe file but the
> dialog style is still the old one.
Off-list, 程梁 found two problems with my suggestion. Correcting them
let him get the new dialog style in his program..
1. The MSDN page I linked to doesn't show a complete example of the
needed XML file, just a partial one.
2. I used a sample file name of example.com.manifest. But it should
have been example.exe.manifest.
Instead of looking at the MSDN page for an example manifest file, you
can use the mt.exe tool (from Microsoft's free Windows SDK) to extract a
working manifest file from an existing program. For example, you can
extract the manifest from notepad.exe with
mt.exe -inputresource:\windows\notepad.exe;#1 -out:extracted.manifest
The result is this manifest file:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1"
manifestVersion="1.0">
<assemblyIdentity name="Microsoft.Windows.Shell.notepad"
processorArchitecture="x86" version="5.1.0.0"
type="win32"></assemblyIdentity>
<description>Windows Shell</description>
<dependency>
<dependentAssembly>
<assemblyIdentity type="win32"
name="Microsoft.Windows.Common-Controls" version="6.0.0.0"
processorArchitecture="x86" publicKeyToken="6595b64144ccf1df"
language="*"></assemblyIdentity>
</dependentAssembly>
</dependency>
</assembly>
Change "Microsoft.Windows.Shell.notepad" to your program's name, and
"Windows Shell" to its description, then rename the file to match your
executable, and you should get a matching common dialog style when you
run it.
Steven
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20100225/6b983ed1/attachment.html
More information about the Qt-interest-old
mailing list