Results 1 to 4 of 4

Thread: QDialog problem with exec()

  1. #1
    Join Date
    Feb 2010
    Posts
    21
    Thanks
    3
    Thanked 1 Time in 1 Post
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default QDialog problem with exec()

    Qt Code:
    1. ...
    2. form_login l;
    3. if (l.exec() == QDialog::Accepted)
    4. {
    5. tmain_form main_form;
    6. main_form.show();
    7. return a.exec();
    8. }
    9. ...
    To copy to clipboard, switch view to plain text mode 

    Hi I'm using this code to show a login form on the main.cpp file.

    When used in this way before the a.exec(), everything works fine.
    But when I try this, the exec() is not executed in the usual way, the dialog is closed not waiting for user action.

    Qt Code:
    1. tcontrol *control = new tcontrol();
    2.  
    3. if (control->login())
    4. {
    5. tmain_form main_form;
    6. main_form.show();
    7. return a.exec();
    8. }
    To copy to clipboard, switch view to plain text mode 

    and login is just a method wrapping the first code, returning (l.exec() == QDialog::Accepted)

    What is the difference?

    I'm missing something?

    Thanks in advance.

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: QDialog problem with exec()

    Disconnect the lastWindowClosed() signal in the application object from its quit() slot.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  3. #3
    Join Date
    Feb 2010
    Posts
    21
    Thanks
    3
    Thanked 1 Time in 1 Post
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: QDialog problem with exec()

    Quote Originally Posted by wysota View Post
    Disconnect the lastWindowClosed() signal in the application object from its quit() slot.
    Thanks for the reply.

    Before the tcontrol *control = new tcontrol(); line, I use this a.setQuitOnLastWindowClosed(false); as I check on documentation:
    void QApplication::lastWindowClosed () [signal]
    ...
    This feature can be turned off by setting quitOnLastWindowClosed to false.
    but the result is the same.

  4. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: QDialog problem with exec()

    Please provide a minimal compilable example reproducing the problem.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


Similar Threads

  1. exec() not blocking, derived QDialog, Qt 4.4.3
    By wdezell in forum Qt Programming
    Replies: 2
    Last Post: 4th August 2009, 18:56
  2. problem with show/exec of Qdialog
    By dudedude in forum Qt Programming
    Replies: 1
    Last Post: 23rd December 2008, 11:20
  3. QDialog::exec : Recursive call detected.
    By node_ex in forum Qt Programming
    Replies: 4
    Last Post: 29th June 2008, 17:50
  4. QDialog: show() and exec() together in constructor?
    By Teuniz in forum Qt Programming
    Replies: 8
    Last Post: 28th February 2007, 11:43
  5. QDialog::exec() cereates no modal dialog
    By sboesch in forum Qt Programming
    Replies: 8
    Last Post: 27th March 2006, 17:03

Tags for this Thread

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.