Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Mobile and Embedded
  4. [Android] rename Buttons of a QMessageBox
Forum Updated to NodeBB v4.3 + New Features

[Android] rename Buttons of a QMessageBox

Scheduled Pinned Locked Moved Mobile and Embedded
6 Posts 4 Posters 3.5k Views 1 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.
  • D Offline
    D Offline
    dualfaces
    wrote on last edited by
    #1

    Hello all,

    i tried various methods to rename two buttons in a QMessageBox, but none of them worked. Here is what i tried
    @
    QMessageBox mbox;
    mbox.setText("Disconnected");
    mbox.setInformativeText("Wait for Reconnect?");
    QPushButton *yesbtn = mbox.addButton(tr("Ja"), QMessageBox::ActionRole);
    QPushButton *nobtn = mbox.addButton(tr("Nein"), QMessageBox::ActionRole);
    mbox.addButton(yesbtn, QMessageBox::ActionRole);
    mbox.addButton(nobtn, QMessageBox::ActionRole);
    mbox.setIcon(QMessageBox::Question);
    mbox.exec();
    @

    With this method no button appears. Second try:
    @
    QMessageBox mbox;

        mbox.setText("Disconnected");
        mbox.setInformativeText("Wait for Reconnect?");
        QPushButton* btnyes = mbox.addButton("Ja", QMessageBox::YesRole);
        QPushButton* btnno = mbox.addButton("Nein", QMessageBox::NoRole);
        mbox.addButton(btnyes, QMessageBox::YesRole);
        mbox.addButton(btnno, QMessageBox::NoRole);
        mbox.setIcon(QMessageBox::Question);
        mbox.exec();
    

    @

    Third method
    @
    QMessageBox mbox;

        mbox.setText("Disconnected");
        mbox.setInformativeText("Wait for reconnect?");
        mbox.setButtonText(QMessageBox::Yes, trUtf8("Ja"));
        mbox.setButtonText(QMessageBox::No, trUtf8("Nein"));
        mbox.setStandardButtons(QMessageBox::Yes | QMessageBox::No);
        mbox.setIcon(QMessageBox::Question);
        mbox.exec();
    

    @

    Fourth method:
    @
    QMessageBox mbox;

        mbox.setText("Verbindung zu BlueMaster getrennt");
        mbox.setInformativeText("Auf BlueMaster warten?");
        mbox.setStandardButtons(QMessageBox::Yes | QMessageBox::No);
        mbox.button(QMessageBox::Yes)->setText("Ja");
        mbox.button(QMessageBox::No)->setText("Nein");
        mbox.setIcon(QMessageBox::Question);
        mbox.exec();
    

    @

    None of them works. What do I have to do to rename the Yes and No-role button?

    Thank you.

    Regards

    1 Reply Last reply
    0
    • D Offline
      D Offline
      dualfaces
      wrote on last edited by
      #2

      Is there no other way or can anyone see a mistake in my code snippets?

      1 Reply Last reply
      0
      • D Offline
        D Offline
        dualfaces
        wrote on last edited by
        #3

        Okay, this is quite strange, even if I try the possibilities listed in the documetation it does not work.

        @
        QMessageBox mbox(this);
        mbox.addButton(tr("Disconnect"), QMessageBox::ActionRole);
        mbox.exec();
        @

        where this is my MainWindow which inherits QMainWindow.
        Executing this piece of code opens an empty box without buttons.

        Thanks for help.

        Regards

        1 Reply Last reply
        0
        • M Offline
          M Offline
          maitai
          wrote on last edited by
          #4

          Same problem here, it seems that QMessageBox::addButton() is broken on Android (qt5.2.1).

          Same code on PC (linux or mac/OS or windows) runs fine.

          1 Reply Last reply
          0
          • SGaistS Offline
            SGaistS Offline
            SGaist
            Lifetime Qt Champion
            wrote on last edited by
            #5

            Hi,

            Please have a look at the "bug report system":http://bugreports.qt-project.org to see whether it's something known. If not consider opening a new but report providing a minimal compilable example reproducing the behavior

            Interested in AI ? www.idiap.ch
            Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

            1 Reply Last reply
            0
            • L Offline
              L Offline
              landrew
              wrote on last edited by
              #6

              This may not be the same bug, but is likely related:
              https://bugreports.qt-project.org/browse/QTBUG-35545

              It has not been resolved for Android yet.

              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