QPushButton has duplicate text after Qt update

I have an Android app written in C ++ using Qt Creator.

After updating the Qt version (from 4.8 to 5.4 ), I observed strange behavior: all QPushButton received a duplicate text label, one is in the right position, and the other is slightly shifted. This behavior can be observed on the Acer Iconia Tab A700 tab , but not on another device (Samsung Galaxy Tab).

illustration of the problem

I created a completely new QDialog menu in QT Creator using only a graphical editor, but it displayed the same thing.

Has anyone else observed the same thing? I am new to Qt and have no idea how to fix this ...

EDIT

Here are some snippets:

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)); ... } 

But then again, I used the Qt Creator GUI to create a dialog, so I guess it should be some configuration error. Or maybe something related to the retranslateUi() function?

Here's what it looks like in Qt Creator:

enter image description here

EDIT No. 2

I dug up some instructions where a specific button style was defined. Here he is:

  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); } 
+7
c ++ android text qt qpushbutton
source share
2 answers

I managed to make progress!

I had to recreate the whole widget, and this time I gave it a little more. Just using QtCreator, scaling the main frame of the widget . Now all button shortcuts are displayed correctly. In addition, the ui element size policy has been changed to Expanding .

Well, I know that this is just a cure, not a solution explaining why this happens, but I am pleased with this result.

0
source share

I have the same problem, I solved this by setting the stylesheet. This seems to be a border issue, a stylesheet that solves the problem:

 border-style: outset; border-width: 2px; border-radius: 4px; border-color: black; padding: 6px; 

I tried a different configuration, but I can not understand what is real, which solves the problem.

+1
source share

All Articles