Results 1 to 4 of 4

Thread: how to get the accept signal by clicking Apply button

  1. #1
    Join Date
    Mar 2009
    Location
    Gansu,China
    Posts
    188
    Qt products
    Qt4
    Platforms
    Windows

    Default how to get the accept signal by clicking Apply button

    I create a myDialog inhereted from QDialog,and add an Apply button,as you know,when click Apply button,the slot applyslot() is used and the dialog window should not be closed.

    I use myDialog as follows:

    Qt Code:
    1. myDialog *mydialog=new myDialog (this);
    2.  
    3. if(mydialog->exec())
    4. {
    5. ......
    6. }
    To copy to clipboard, switch view to plain text mode 
    for not used accepted() in applyslot(),so applyslot() does not do,how to let the slot applyslot() do and the window does not close?
    Last edited by wysota; 6th January 2012 at 01:39.

  2. #2
    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: how to get the accept signal by clicking Apply button

    Do not do anything in the applyslot() that will close the dialog. That is, do not call close(), accept(), reject(), or done() or anything that calls them.

  3. #3
    Join Date
    Mar 2009
    Location
    Gansu,China
    Posts
    188
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: how to get the accept signal by clicking Apply button

    Quote Originally Posted by ChrisW67 View Post
    Do not do anything in the applyslot() that will close the dialog. That is, do not call close(), accept(), reject(), or done() or anything that calls them.
    If I do as you said,the result of
    Qt Code:
    1. mydialog->exec()
    To copy to clipboard, switch view to plain text mode 
    will be false,because only accept() or done() is called ,it will be true.

  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: how to get the accept signal by clicking Apply button

    If you continue with a modal dialog then it has three buttons:
    • OK: Press this, pending stuff is done, accept() is called, the dialog closed, and true returned.
    • Cancel: Press this, pending stuff is not done, reject() is called, the dialog closed, and false returned.
    • Apply: Press this, pending stuff is done, nothing is done that would close the dialog, and exec() does not return.


    If you want a non-modal dialog then call show() not exec(). You do not get a boolean return this way so you may need to reconsider how stuff is done.

Similar Threads

  1. emitting a signal with no button?
    By kja in forum Newbie
    Replies: 3
    Last Post: 29th November 2010, 21:33
  2. Apply button in Configuration dialog
    By UVV in forum Qt Programming
    Replies: 1
    Last Post: 24th October 2010, 10:36
  3. Replies: 7
    Last Post: 5th January 2009, 08:27
  4. Replies: 2
    Last Post: 14th November 2006, 11:22

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.