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
Forum Updated to NodeBB v4.3 + New Features

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.
  • J Offline
    J Offline
    joaopagotto
    wrote on 14 Dec 2016, 18:08 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.

    J 1 Reply Last reply 15 Dec 2016, 06:20
    0
    • J joaopagotto
      14 Dec 2016, 18:08

      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.

      J Online
      J Online
      jsulm
      Lifetime Qt Champion
      wrote on 15 Dec 2016, 06:20 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
      • J Offline
        J Offline
        joaopagotto
        wrote on 15 Dec 2016, 10:41 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();
        
        J 1 Reply Last reply 15 Dec 2016, 11:26
        0
        • J joaopagotto
          15 Dec 2016, 10:41

          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();
          
          J Online
          J Online
          jsulm
          Lifetime Qt Champion
          wrote on 15 Dec 2016, 11:26 last edited by
          #4

          @joaopagotto What Qt version do you use?

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

          J 1 Reply Last reply 15 Dec 2016, 11:27
          1
          • J jsulm
            15 Dec 2016, 11:26

            @joaopagotto What Qt version do you use?

            J Offline
            J Offline
            joaopagotto
            wrote on 15 Dec 2016, 11:27 last edited by
            #5

            @jsulm Qt 5.7.0 and Qt 5.7.1 same problem.

            J D 2 Replies Last reply 15 Dec 2016, 11:30
            0
            • J joaopagotto
              15 Dec 2016, 11:27

              @jsulm Qt 5.7.0 and Qt 5.7.1 same problem.

              J Online
              J Online
              jsulm
              Lifetime Qt Champion
              wrote on 15 Dec 2016, 11:30 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
              • J joaopagotto
                15 Dec 2016, 11:27

                @jsulm Qt 5.7.0 and Qt 5.7.1 same problem.

                D Offline
                D Offline
                Devopia53
                wrote on 15 Dec 2016, 12:29 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");

                J 1 Reply Last reply 15 Dec 2016, 13:23
                2
                • D Devopia53
                  15 Dec 2016, 12:29

                  @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");

                  J Offline
                  J Offline
                  joaopagotto
                  wrote on 15 Dec 2016, 13:23 last edited by
                  #8

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

                  1 Reply Last reply
                  0

                  1/8

                  14 Dec 2016, 18:08

                  • Login

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