[Android] rename Buttons of a QMessageBox



  • 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



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



  • 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



  • 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.


  • Lifetime Qt Champion

    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



  • 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.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.