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. What is the actual function of this BottonRole?
Forum Update on Monday, May 27th 2025

What is the actual function of this BottonRole?

Scheduled Pinned Locked Moved Solved General and Desktop
3 Posts 2 Posters 205 Views
  • 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.
  • GaoboG Offline
    GaoboG Offline
    Gaobo
    wrote on last edited by
    #1

    I was reading QMessageBox, and I saw that a parameter in the addButton function is BottonRole. What is the actual function of this BottonRole?Please forgive my poor English, I translated through the translation software

    1 Reply Last reply
    0
    • VRoninV Offline
      VRoninV Offline
      VRonin
      wrote on last edited by
      #2

      It's described here: https://doc.qt.io/qt-6/qmessagebox.html#ButtonRole-enum
      It is used to display the button in the correct place on systems (like MacOS) where position changes depending on the function

      "La mort n'est rien, mais vivre vaincu et sans gloire, c'est mourir tous les jours"
      ~Napoleon Bonaparte

      On a crusade to banish setIndexWidget() from the holy land of Qt

      GaoboG 1 Reply Last reply
      2
      • VRoninV VRonin

        It's described here: https://doc.qt.io/qt-6/qmessagebox.html#ButtonRole-enum
        It is used to display the button in the correct place on systems (like MacOS) where position changes depending on the function

        GaoboG Offline
        GaoboG Offline
        Gaobo
        wrote on last edited by
        #3

        @VRonin Thanks,

            QMessageBox* box = new QMessageBox(this);
            QPushButton* button1 = new QPushButton("是",this);
            box->addButton(button1, QMessageBox::NoRole);
        
            QPushButton* button = new QPushButton("否",this);
            box->addButton(button, QMessageBox::YesRole);
            box->show();
        

        I wrote some code and after running it I got the following result
        b037265a-5402-4d34-9a13-bc252dd7495c-image.png
        Now I understand what you mean,Thank you!
        If my expression offends you, please do not mind. (^ _ ^)

        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