Results 1 to 10 of 10

Thread: slot "return" close my GUI app

  1. #1
    Join Date
    Oct 2010
    Location
    Tijuana, Baja California, México
    Posts
    19
    Thanks
    2
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default slot "return" close my GUI app

    Hi, I have a slot for qpushbutton:
    Qt Code:
    1. connect(button1, SIGNAL(clicked()), this, SLOT(handleButtonClicked()));
    2. /* more code */
    3. protected slots:
    4. void handleButtonClicked()
    5. {
    6. qDebug() << "Clicked handler";
    7. /* test if you want to continue the event */
    8. int ret = QMessageBox::question(...);
    9. if (ret != QMessageBox::Yes) {
    10. return; // cancel the propagation?
    11. }
    12. qDebug() << "Glad that you join us";
    13. }
    To copy to clipboard, switch view to plain text mode 
    my problem is that when I hit "No", the window closes
    any ideas?
    Last edited by Joelito; 13th March 2014 at 20:33.

  2. #2
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: slot "return" close my GUI app

    Quote Originally Posted by Joelito View Post
    my problem is that when I hit "No", the window closes
    Which has nothing to do with your code.

    Quote Originally Posted by Joelito View Post
    any ideas?
    No. Not enough information to even guess.

    Cheers,
    _

  3. #3
    Join Date
    Oct 2010
    Location
    Tijuana, Baja California, México
    Posts
    19
    Thanks
    2
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: slot "return" close my GUI app

    When I hit button in my app (buttton1) there's a QMessageBox with yes and no buttons...if the user hits "no" button in the QMessageBox, the GUI closes. So the expected situation is that after the "no" button the function returns or exits without displaying Glad that you join us

  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: slot "return" close my GUI app

    That is not happening in the code you are showing us. Run your program in your debugger and single step through this slot to find out where it actually "closes", whether that is an abnormal or normal termination, and the actual trigger for it.

  5. #5
    Join Date
    Oct 2013
    Posts
    41
    Thanks
    1
    Thanked 8 Times in 7 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: slot "return" close my GUI app

    why dont you use a switch statement on the return from the dialog and catch the no response, then try to do something other than return? maybe add a breakpoint and debug it.

  6. #6
    Join Date
    Oct 2010
    Location
    Tijuana, Baja California, México
    Posts
    19
    Thanks
    2
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: slot "return" close my GUI app

    The debugger is clean:
    [New Thread 0xac796b40 (LWP 1368)]
    [Thread 0xac796b40 (LWP 1368) exited]
    [Inferior 1 (process 1362) exited normally]
    (gdb) where
    No stack.
    (gdb)

  7. #7
    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: slot "return" close my GUI app

    And where did it exit from after the slot call returned?

  8. #8
    Join Date
    Oct 2010
    Location
    Tijuana, Baja California, México
    Posts
    19
    Thanks
    2
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: slot "return" close my GUI app

    I think I know the problem:

    1.- If the GUI is visible the QMessageBox responds as expected and the function returns if I click and the "No" button; the GUI stills active.
    2.- But if the GUI is hidden ans I display the QMessageBox, the GUI closes after I click "No".

    :-/

  9. #9
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: slot "return" close my GUI app

    Does it help if you set http://qt-project.org/doc/qt-4.8/qap...dowClosed-prop to false?

    Cheers,
    _

  10. The following user says thank you to anda_skoa for this useful post:

    Joelito (15th March 2014)

  11. #10
    Join Date
    Oct 2010
    Location
    Tijuana, Baja California, México
    Posts
    19
    Thanks
    2
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: slot "return" close my GUI app

    Thanks for the tip, @anda_skoa. It did help and also I think QMessageBox needs a valid parent pointer to avoid the application exits.

Similar Threads

  1. How to hide Close Button "X" on Widget ?
    By merry in forum Qt Programming
    Replies: 8
    Last Post: 25th January 2020, 08:03
  2. QtextEdti changes "cariage return" to "linefeed"
    By StefanQtNutzer in forum Qt Programming
    Replies: 2
    Last Post: 6th December 2010, 11:58
  3. debugging "signal does not reach slot" in a template class
    By Daniel Dekkers in forum Qt Programming
    Replies: 1
    Last Post: 3rd April 2010, 16:03
  4. Translation QFileDialog standart buttons ("Open"/"Save"/"Cancel")
    By victor.yacovlev in forum Qt Programming
    Replies: 4
    Last Post: 24th January 2008, 19:05
  5. How to "hide window when close button pressed"
    By iGoo in forum Qt Programming
    Replies: 4
    Last Post: 26th July 2006, 09:53

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.