Results 1 to 4 of 4

Thread: Non Qt application, wants a modal Qt dialog. Is this possible?

  1. #1
    Join Date
    Mar 2010
    Posts
    1
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Non Qt application, wants a modal Qt dialog. Is this possible?

    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?

  2. #2
    Join Date
    Dec 2010
    Posts
    4
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Non Qt application, wants a modal Qt dialog. Is this possible?

    Any answers?
    I passed parent(HWND of MFC View) to the dialog, however, it is still not modal.

  3. #3
    Join Date
    Oct 2010
    Location
    Berlin, Germany
    Posts
    358
    Thanks
    18
    Thanked 68 Times in 66 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Non Qt application, wants a modal Qt dialog. Is this possible?

    don't call exec(). use "show()" instead...

  4. #4
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: Non Qt application, wants a modal Qt dialog. Is this possible?

    Quote Originally Posted by cuiqimeng View Post
    Any answers?
    I passed parent(HWND of MFC View) to the dialog, however, it is still not modal.
    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...r/qtwinmigrate

    Quote Originally Posted by FelixB View Post
    don't call exec(). use "show()" instead...
    This will, by default, give a non-modal QDialog.

Similar Threads

  1. QT Modal Dialog
    By jiapei100 in forum Qt Programming
    Replies: 1
    Last Post: 16th January 2010, 17:15
  2. Non-modal dialog forces app to exit.
    By vereteran in forum Newbie
    Replies: 1
    Last Post: 17th October 2009, 08:39
  3. Modal dialog not behaving
    By tpf80 in forum Qt Programming
    Replies: 7
    Last Post: 16th September 2008, 22:03
  4. Special Modal Dialog
    By adonel in forum Qt Programming
    Replies: 2
    Last Post: 13th May 2008, 08:12
  5. System modal dialog!!
    By boss_bhat in forum Qt Programming
    Replies: 2
    Last Post: 23rd June 2006, 07:01

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.