Results 1 to 9 of 9

Thread: QButtonBox, how to find index of QDialogButtonBox::Ok

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jul 2015
    Posts
    87
    Thanks
    1
    Thanked 4 Times in 4 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: QButtonBox, how to find index of QDialogButtonBox::Ok

    Quote Originally Posted by anda_skoa View Post
    Not really, the actual solution is already in comment #2

    Cheers,
    _
    #2 only works if "OK" is the standard button of the dialog, IMO it doesn't work if you want to
    change "retry" or "cancel" etc., my solution is a general way i guess.

  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: QButtonBox, how to find index of QDialogButtonBox::Ok

    Quote Originally Posted by HappyCoder View Post
    #2 only works if "OK" is the standard button of the dialog
    No, it works regardless of which button is the default.

    Quote Originally Posted by HappyCoder View Post
    IMO it doesn't work if you want to change "retry" or "cancel" etc.
    Yes, it does.

    Quote Originally Posted by HappyCoder View Post
    my solution is a general way i guess.
    It is no more generic, just less efficient and with more unnecessary code.

    Cheers,
    _

  3. #3
    Join Date
    Jul 2015
    Posts
    87
    Thanks
    1
    Thanked 4 Times in 4 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: QButtonBox, how to find index of QDialogButtonBox::Ok

    Ok, i think i got it

    Qt Code:
    1. ui->buttonBox->button( QDialogButtonBox::Ok )->setText( tr("Export"));
    To copy to clipboard, switch view to plain text mode 

  4. #4
    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: QButtonBox, how to find index of QDialogButtonBox::Ok

    Exactly!

    Way shorter and simpler, wouldn't you agree?

    Cheers,
    _

  5. #5
    Join Date
    Mar 2008
    Location
    Kraków, Poland
    Posts
    1,540
    Thanked 284 Times in 279 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QButtonBox, how to find index of QDialogButtonBox::Ok

    And so it will be safer when there is no button :
    Qt Code:
    1. QPushButton *ptr = ui->buttonBox->button( QDialogButtonBox::Ok );
    2. if( ptr )
    3. ptr->setText( tr("Export"));
    To copy to clipboard, switch view to plain text mode 

Similar Threads

  1. Find item index in QGraphicsLinearLayout
    By bmn in forum Qt Programming
    Replies: 1
    Last Post: 23rd May 2014, 00:06
  2. Replies: 2
    Last Post: 13th March 2014, 19:11
  3. How to find out row index of a QTableWidget.
    By Niamita in forum Qt Programming
    Replies: 1
    Last Post: 19th April 2012, 15:32
  4. Replies: 1
    Last Post: 14th September 2010, 16:26
  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
  •  
Qt is a trademark of The Qt Company.