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. Problem with setButtonText on QMessageBox - Android

Problem with setButtonText on QMessageBox - Android

Scheduled Pinned Locked Moved Solved Mobile and Embedded
8 Posts 3 Posters 3.1k 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.
  • joaopagottoJ Offline
    joaopagottoJ Offline
    joaopagotto
    wrote on last edited by joaopagotto
    #1

    Hi.
    I have a problem with QMessageBox, the property setButtonText not change text of default button yes/no to my language, in this case pt_BR.
    When execute, applications on all devices Android show [YES] [NO] instead [SIM] [NÃO].

    This is my code:

       QMessageBox *msg = new QMessageBox(this);
       msg->setText("Deseja cancelar ?");
       msg->setStandardButtons(QMessageBox::Yes |QMessageBox::No);
       msg->setButtonText(QMessageBox::Yes, "Sim");
       msg->setButtonText(QMessageBox::No, "Não");
       msg->exec();
    

    see device screenshot
    alt text

    Thanks.

    jsulmJ 1 Reply Last reply
    0
    • joaopagottoJ joaopagotto

      Hi.
      I have a problem with QMessageBox, the property setButtonText not change text of default button yes/no to my language, in this case pt_BR.
      When execute, applications on all devices Android show [YES] [NO] instead [SIM] [NÃO].

      This is my code:

         QMessageBox *msg = new QMessageBox(this);
         msg->setText("Deseja cancelar ?");
         msg->setStandardButtons(QMessageBox::Yes |QMessageBox::No);
         msg->setButtonText(QMessageBox::Yes, "Sim");
         msg->setButtonText(QMessageBox::No, "Não");
         msg->exec();
      

      see device screenshot
      alt text

      Thanks.

      jsulmJ Offline
      jsulmJ Offline
      jsulm
      Lifetime Qt Champion
      wrote on last edited by
      #2

      @joaopagotto See http://doc.qt.io/qt-5/qmessagebox-obsolete.html

      The following members of class QMessageBox are obsolete. They are provided to keep old source code working. We strongly advise against using them in new code.
      

      You should use http://doc.qt.io/qt-5/qmessagebox.html#addButton instead.

      https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      1
      • joaopagottoJ Offline
        joaopagottoJ Offline
        joaopagotto
        wrote on last edited by
        #3

        Well. I try follow your tip, but doesn't work.
        See my code and screenshots below.
        Can it be bug in the Qt libraries for Android ?

        This my code:

           QMessageBox msg;
           msg.setText("Deseja cancelar ?");
           msg.addButton("Sim", QMessageBox::YesRole);
           msg.addButton("Nao", QMessageBox::NoRole);
           msg.exec();
        

        On Windows MSVC2015-x32
        alt text

        On Android arm7 6.0
        alt text

        This code sample in QMessageBox doc, but button "Connect" doesn't appear, only Abort Button:

        QMessageBox msgBox;
        QPushButton *connectButton = msgBox.addButton(tr("Connect"), QMessageBox::ActionRole);
        QPushButton *abortButton = msgBox.addButton(QMessageBox::Abort);
        msgBox.exec();
        
        jsulmJ 1 Reply Last reply
        0
        • joaopagottoJ joaopagotto

          Well. I try follow your tip, but doesn't work.
          See my code and screenshots below.
          Can it be bug in the Qt libraries for Android ?

          This my code:

             QMessageBox msg;
             msg.setText("Deseja cancelar ?");
             msg.addButton("Sim", QMessageBox::YesRole);
             msg.addButton("Nao", QMessageBox::NoRole);
             msg.exec();
          

          On Windows MSVC2015-x32
          alt text

          On Android arm7 6.0
          alt text

          This code sample in QMessageBox doc, but button "Connect" doesn't appear, only Abort Button:

          QMessageBox msgBox;
          QPushButton *connectButton = msgBox.addButton(tr("Connect"), QMessageBox::ActionRole);
          QPushButton *abortButton = msgBox.addButton(QMessageBox::Abort);
          msgBox.exec();
          
          jsulmJ Offline
          jsulmJ Offline
          jsulm
          Lifetime Qt Champion
          wrote on last edited by
          #4

          @joaopagotto What Qt version do you use?

          https://forum.qt.io/topic/113070/qt-code-of-conduct

          joaopagottoJ 1 Reply Last reply
          1
          • jsulmJ jsulm

            @joaopagotto What Qt version do you use?

            joaopagottoJ Offline
            joaopagottoJ Offline
            joaopagotto
            wrote on last edited by
            #5

            @jsulm Qt 5.7.0 and Qt 5.7.1 same problem.

            jsulmJ D 2 Replies Last reply
            0
            • joaopagottoJ joaopagotto

              @jsulm Qt 5.7.0 and Qt 5.7.1 same problem.

              jsulmJ Offline
              jsulmJ Offline
              jsulm
              Lifetime Qt Champion
              wrote on last edited by
              #6

              @joaopagotto Could be that it is not supported on Android. Maybe anybody else knows?

              https://forum.qt.io/topic/113070/qt-code-of-conduct

              1 Reply Last reply
              0
              • joaopagottoJ joaopagotto

                @jsulm Qt 5.7.0 and Qt 5.7.1 same problem.

                D Offline
                D Offline
                Devopia53
                wrote on last edited by
                #7

                @joaopagotto

                AFAIK, Qt is not provided it on Android native style except default buttons.
                If you want to use the Qt style, try this: qputenv("QT_USE_ANDROID_NATIVE_DIALOGS", "0");

                joaopagottoJ 1 Reply Last reply
                2
                • D Devopia53

                  @joaopagotto

                  AFAIK, Qt is not provided it on Android native style except default buttons.
                  If you want to use the Qt style, try this: qputenv("QT_USE_ANDROID_NATIVE_DIALOGS", "0");

                  joaopagottoJ Offline
                  joaopagottoJ Offline
                  joaopagotto
                  wrote on last edited by
                  #8

                  @Devopia53 this works very well ! Thank you so much ! =D

                  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