I have an Android application written in C++ using Qt Creator.
After the Qt version upgrade (from 4.8 to 5.4) I observed a strange behaviour: all QPushButton got duplicated text label, one is at the correct position and the other is shifted a bit away. This behaviour can be observed on Acer Iconia Tab A700 but not on other device (Samsung Galaxy Tab).
I have created a whole new QDialog menu in QT Creator, using just the graphical editor, but it displayed the same thing.
Did someone else observe the same thing? I am quite new in 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 again, I used the Qt Creator GUI to create the dialog, so my guess is that this should be some configuration error. Or maybe something related to the retranslateUi()
function?
This is how it looks in Qt Creator:
EDIT #2
I dug up some instruction where the concrete style of the buttons were defined. Here it 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);
}