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. QPushButton with duplicated text
QtWS25 Last Chance

QPushButton with duplicated text

Scheduled Pinned Locked Moved Mobile and Embedded
qpushbuttonqt5androidc++
7 Posts 3 Posters 2.5k 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.
  • S Offline
    S Offline
    SteveMBay
    wrote on last edited by SteveMBay
    #1

    Hello guys,
    I have an Android application written in C++ using Qt Creator.

    After the Qt version upgrade (from 4 to 5) I observed a strange behavior: all QPushButton got duplicated text label, one is at the correct position and the other is shifted a bit away.

    To clear the situation, I have created a whole new QDialog menu in QT Creator, using just the graphical editor, but it displayed the same thing.

    This is how it looks in the Creator:
    View in Creator

    mydialog.ui:

    <widget class="QPushButton" name="startButton">
     <property name="sizePolicy">
      <sizepolicy hsizetype="Minimum" vsizetype="Minimum">
       <horstretch>0</horstretch>
       <verstretch>0</verstretch>
      </sizepolicy>
     </property>
     <property name="text">
      <string>Start</string>
     </property>
     <property name="default">
      <bool>true</bool>
     </property>
    </widget>
    

    ui_mydialog.h:

    public:
    QPushButton *startButton;
    QPushButton *stopButton;
    ...
    void setupUi(QDialog *MyDialog)
    {
      ... // some layout stuff here
      startButton = new QPushButton(MyDialog);
      startButton->setObjectName(QStringLiteral("startButton"));
      QSizePolicy sizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum);
      sizePolicy.setHorizontalStretch(0);
      sizePolicy.setVerticalStretch(0);
      sizePolicy.setHeightForWidth(startButton->sizePolicy().hasHeightForWidth());
      startButton->setSizePolicy(sizePolicy);
      startButton->setDefault(true);
      ... // later
      QWidget::setTabOrder(startButton, stopButton);
     }
      
     void retranslateUi(QDialog *MyDialog)
     {
      MyDialog->setWindowTitle(QApplication::translate("MyDialog", "Dialog", 0));
      startButton->setText(QApplication::translate("MyDialog", "Start", 0));
      stopButton->setText(QApplication::translate("MyDialog", "Stop", 0));
      ...
     }
    

    And this is the result:
    Result on Android

    I have also looked trough the Qt bug tracker but nothing...

    Did someone else observe the similar anomaly?

    EDIT
    I have found the part where the style of the buttons are defined. May this helps somehow....

    foreach (QToolButton* bt, listOfToolButtons) {
        bt->setAttribute(Qt::WA_AcceptTouchEvents);
        bt->installEventFilter(scrollAreaForToolBar);
        bt->setIconSize(QSize(iconSize, iconSize));
        bt->setStyleSheet("QToolButton{ background-color: #051a49; border: none;}");
        scrollAreaContainer->layout()->addWidget(bt);
    }
    
    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi and welcome to devnet,

      I'd recommend bringing this question to the Android-development mailing list. You'll find the Qt's Android port developers/maintainers (this forum is more user oriented)

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

      S 1 Reply Last reply
      0
      • SGaistS SGaist

        Hi and welcome to devnet,

        I'd recommend bringing this question to the Android-development mailing list. You'll find the Qt's Android port developers/maintainers (this forum is more user oriented)

        S Offline
        S Offline
        SteveMBay
        wrote on last edited by
        #3

        @SGaist Thanks for the advice, but I want to play safe before blaming the devs :D
        I spot something: on a different device the entire UI looks different. I will look for the used style definitions.

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

          Who talked about blaming ? ;)

          Asking if someone encountered the same problem isn't a bad thing to do

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

          S 1 Reply Last reply
          0
          • SGaistS SGaist

            Who talked about blaming ? ;)

            Asking if someone encountered the same problem isn't a bad thing to do

            S Offline
            S Offline
            SteveMBay
            wrote on last edited by
            #5

            Okay, okay :) I've found the part what I wanted to before asking them. Now the question is detailed enough.

            1 Reply Last reply
            0
            • J Offline
              J Offline
              JeromeV
              wrote on last edited by JeromeV
              #6

              Hello

              I am porting a Qt application to Android and I have the same problem with QPushButton only whan I use ministro to install Qt libs. When I ask Qt Creator to bunble Qt libs in package, there is no problem. Looks like a problem of librairie difference.

              PS : I am using Qt 5.4, Qt Creator 3.3.0 and Ministro 10.3.

              1 Reply Last reply
              0
              • S Offline
                S Offline
                SteveMBay
                wrote on last edited by SteveMBay
                #7

                Hello again!

                I managed some progress!

                I had to recreate the entire widget and this time I gave a bit more size to it.
                Just using QtCreator, scaling the main frame of the widget. Now, all button label is dispalyed correctly.

                Also, the size policy of the ui elements has been changed to Expanding.

                Okay, I know that this is just a treatment of the problem and does not explain why it occurs, but I am happy with this result now. :)

                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