PDA

View Full Version : Non Qt application, wants a modal Qt dialog. Is this possible?



asterisc
1st March 2010, 13:29
I had a windows application (non Qt), and I integrated Qt some years later, and now, I have a Qt dialog which I would like to be modal for the whole application.

Is this possible?

I have a class which derives QDialog. I tried both:
setModal( true ); in its constructor, and:
setWindowModality( Qt::ApplicationModal ); both in its constructor and from the place that I call it.

I call it like:
BrowseDialog dlg(...);
int result = dlg.exec();

I don't pass him any parent.

Is it possible to have that dialog modal for the whole application?

cuiqimeng
16th December 2010, 02:44
Any answers?
I passed parent(HWND of MFC View) to the dialog, however, it is still not modal.:confused::confused:

FelixB
16th December 2010, 09:16
don't call exec(). use "show()" instead...

ChrisW67
17th December 2010, 02:06
Any answers?
I passed parent(HWND of MFC View) to the dialog, however, it is still not modal.:confused::confused:
Since a QObject parant is a QObject* and you were giving it a number with meaning only to Windows it is hardly surprising that it doesn't work. It is surprising that it compiled.

I assume that the main application is still a non-Qt application and is therefore not connected with the Qt event loop. There is a some information on how to migrate MFC to Qt http://doc.qt.nokia.com/solutions/4/qtwinmigrate

There is also a defunct Qt Solution to assist with this integration. The source is: http://qt.gitorious.org/qt-solutions/qt-solutions/trees/master/qtwinmigrate


don't call exec(). use "show()" instead...
This will, by default, give a non-modal QDialog.