Results 1 to 6 of 6

Thread: QDialogButtonBox ResetRole

  1. #1
    Join Date
    Sep 2009
    Location
    Warsaw/Poland
    Posts
    56
    Thanks
    8
    Thanked 4 Times in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default QDialogButtonBox ResetRole

    I have QDialogButtonBox with "Reset" "OK" and "Close"
    To OK and Close I use:
    Qt Code:
    1. QObject::connect(ui.buttonBox, SIGNAL(accepted()), this, SLOT(button_ok()));
    2. QObject::connect(ui.buttonBox, SIGNAL(rejected()), this, SLOT(button_close()));
    To copy to clipboard, switch view to plain text mode 

    How write code to Reset button ? I don't find any examples for ResetRole ...

  2. #2
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    4,380
    Thanks
    19
    Thanked 1,005 Times in 913 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60
    Wiki edits
    5

    Default Re: QDialogButtonBox ResetRole

    See the QDialogButtonBox::clicked() signal.

  3. #3
    Join Date
    Sep 2009
    Location
    Warsaw/Poland
    Posts
    56
    Thanks
    8
    Thanked 4 Times in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QDialogButtonBox ResetRole

    something like this ?

    Qt Code:
    1. ...
    2. QObject::connect(ui.buttonBox, SIGNAL(clicked(QAbstractButton*)), this, SLOT(buttons(QAbstractButton*)));
    3. }
    4.  
    5. void class::buttons(QAbstractButton *button)
    6. {
    7. if (button->text() == tr("Reset"))
    8. button_reset();
    9. else if (button->text() == tr("OK"))
    10. button_ok();
    11. else if (button->text() == tr("Close"))
    12. button_close();
    13. }
    To copy to clipboard, switch view to plain text mode 

  4. #4
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    4,380
    Thanks
    19
    Thanked 1,005 Times in 913 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60
    Wiki edits
    5

    Default Re: QDialogButtonBox ResetRole

    Yes, but better:
    Qt Code:
    1. if (ui.buttonBox->button(QDialogButtonBox::Help) == button)
    2. // Help was clicked
    To copy to clipboard, switch view to plain text mode 

  5. #5
    Join Date
    Feb 2011
    Location
    Italy
    Posts
    2
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Unix/X11

    Cool Re: QDialogButtonBox ResetRole

    In qt 4.7 I found that a beter solution is
    Qt Code:
    1. if(ui->buttonBox->standardButton(button) == QDialogButtonBox::Reset)
    2. {
    3. //Do Something
    4. }
    To copy to clipboard, switch view to plain text mode 

  6. #6
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    4,380
    Thanks
    19
    Thanked 1,005 Times in 913 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60
    Wiki edits
    5

    Default Re: QDialogButtonBox ResetRole

    And would you kindly elaborate, why your solution is better? It seems to me you are saying that
    Qt Code:
    1. int i = 1 + 2;
    To copy to clipboard, switch view to plain text mode 
    is better than
    Qt Code:
    1. int i = 2 + 1;
    To copy to clipboard, switch view to plain text mode 

Similar Threads

  1. QDialogButtonBox text not painted
    By kshi in forum Qt Programming
    Replies: 0
    Last Post: 8th January 2011, 00:41
  2. Replies: 1
    Last Post: 8th January 2010, 11:45
  3. Replies: 1
    Last Post: 29th July 2009, 20:25
  4. How to remove default 'ENTER' from QDialogButtonBox
    By janus in forum Qt Programming
    Replies: 6
    Last Post: 12th September 2008, 21:56
  5. a QDialogButtonBox question
    By bnilsson in forum Qt Programming
    Replies: 3
    Last Post: 16th July 2008, 22:42

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.