Details
-
Bug
-
Resolution: Unresolved
-
P2: Important
-
None
-
5.8.0
-
None
-
Linux, touch screen (eGalax Inc. eGalaxTouch EXC7200-72E1)
Description
I ran into a problem with QPushButtons on a touch screen device when I upgraded my application from Qt 4.8.4 to 5.8.0.
Preconditions:
- Two QPushButtons
- Touch screen device
Steps to reproduce:
- Try to push both buttons at the same time
Expected result:
- One of the buttons emits pressed(), released(), and clicked() signals in sequence, the other button emits nothing
- This is how it worked in Qt 4.8.4
Actual result:
- One of the buttons emits pressed(), and no other signals are emitted
- That button stays down even though it is not a checkable button
- If I now push the same button again, it emits released() and clicked() and pops up
- If I instead click somewhere else on the screen, the button emits only released() and pops up
- This is how it now works in Qt 5.8.0
This is really easy to reproduce, happens almost every time I try it. And like mentioned, the same code works without problems in Qt 4.8.
Simple example application demonstrating the problem:
main.cpp:
#include "mainwindow.h" #include <QApplication> int main(int argc, char *argv[]) { QApplication a(argc, argv); MainWindow w; w.show(); return a.exec(); }
mainwindow.cpp:
#include "mainwindow.h" #include <QPushButton> #include <QHBoxLayout> #include <QtGlobal> #include <QDebug> MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent) { setFixedSize(600, 400); QWidget *w = new QWidget; QHBoxLayout *l = new QHBoxLayout; QPushButton *b = new QPushButton("A"); connect(b, SIGNAL(pressed()), this, SLOT(buttonPressed())); connect(b, SIGNAL(released()), this, SLOT(buttonReleased())); connect(b, SIGNAL(clicked(bool)), this, SLOT(buttonClicked())); b->setFixedSize(275, 200); l->addWidget(b); b = new QPushButton("B"); connect(b, SIGNAL(pressed()), this, SLOT(buttonPressed())); connect(b, SIGNAL(released()), this, SLOT(buttonReleased())); connect(b, SIGNAL(clicked(bool)), this, SLOT(buttonClicked())); b->setFixedSize(275, 200); l->addWidget(b); w->setLayout(l); setCentralWidget(w); #if QT_VERSION < QT_VERSION_CHECK(5, 0, 0) m_version = "QT4"; #else m_version = "QT5"; #endif } MainWindow::~MainWindow() { } void MainWindow::buttonPressed() { QPushButton *b = qobject_cast<QPushButton*>(sender()); qDebug() << "PRESSED" << b->text() << m_version; } void MainWindow::buttonReleased() { QPushButton *b = qobject_cast<QPushButton*>(sender()); qDebug() << "RELEASED" << b->text() << m_version; } void MainWindow::buttonClicked() { QPushButton *b = qobject_cast<QPushButton*>(sender()); qDebug() << "CLICKED" << b->text() << m_version; }
mainwindow.h:
#ifndef MAINWINDOW_H #define MAINWINDOW_H #include <QMainWindow> class MainWindow : public QMainWindow { Q_OBJECT public: MainWindow(QWidget *parent = 0); ~MainWindow(); private slots: void buttonPressed(); void buttonReleased(); void buttonClicked(); private: QString m_version; }; #endif // MAINWINDOW_H
PushButtonTest.pro:
QT += core gui greaterThan(QT_MAJOR_VERSION, 4): QT += widgets TARGET = PushButtonTest TEMPLATE = app SOURCES += main.cpp\ mainwindow.cpp HEADERS += mainwindow.h