[Qt-interest] QFileDialog: native + sheet (Window modal) not possible?

Nikos Chantziaras realnc at arcor.de
Thu Jan 27 22:02:53 CET 2011


On 01/27/2011 07:52 PM, Oliver.Knoll at comit.ch wrote:
> On 2011-01-27 Nikos Nikos Chantziaras wrote:
>
>> On 01/27/2011 06:32 PM, Oliver.Knoll at comit.ch wrote:
>>> Hi,
>>>
>>> can anyone confirm my assumption here, that with the current Qt 4.7.1
>>> it is apparently not possible to have both
>>>
>>> * native dialogs and
>>> * Window modal dialogs (aka Sheets on Mac)
>> (http://labs.qt.nokia.com/2010/02/23/unpredictable-exec/)
>>
>> Works just fine here.  Make sure to open the dialog with open(), not exec():
>
> Yes, I am using open(). But on Windows that really gives me the "Qt file dialog", not the native one.
>
>>     file:///usr/share/doc/qt-4.7.1/html/qfiledialog.html#open
>> Doing that I get a native OS X file dialog as a sheet.
>
> At least on Mac OS X then it works as expected! :)
>
> Thanks for confirming this! I will eagerly try this out myself tonight. :)

Btw, you can also use sheets with application-modal dialogs.  Example:

   QFileDialog diag(this);
   diag.setWindowModality(Qt::WindowModal);
   diag.exec();

exec() makes the dialog modal, but it's still a sheet.  I actually use 
this because my application is not multi-document based and exec() is 
simpler to use than open() since it blocks.

I'm not sure if this is intended to be used like this, but it works. 
Note that you can do this with any dialog, not just QFileDialog.



More information about the Qt-interest-old mailing list