Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. QMessegeBox detailedText() change button label
Forum Updated to NodeBB v4.3 + New Features

QMessegeBox detailedText() change button label

Scheduled Pinned Locked Moved General and Desktop
detailedtextqmessegeboxshowdetailhidedetail
2 Posts 2 Posters 1.3k Views 2 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • F Offline
    F Offline
    Fikoblin
    wrote on last edited by
    #1

    Hello,
    How can I change label of button Show Details.../Hide Details..., after setting detailed text property in QMessageBox class?

    1 Reply Last reply
    0
    • Chris KawaC Offline
      Chris KawaC Offline
      Chris Kawa
      Lifetime Qt Champion
      wrote on last edited by Chris Kawa
      #2

      Hi, welcome to devnet.

      Although it's somewhat nonstandard behavior, you can do something like this:

      auto buttons = box.buttons();
      auto it = std::find_if(buttons.begin(), buttons.end(), [&](QAbstractButton* btn){
          return box.buttonRole(btn) == QMessageBox::ActionRole;
      });
      if(it != buttons.end())
         (*it)->setText("Foo bar");
      

      Note though that the text is set every time the button is clicked, so you might want to connect to the clicked signal of that button and change your text there.

      1 Reply Last reply
      0

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved