[Interest] QLineEdit widget background color latency, in Windows 8 with Qt 4.8.4/MinGW 4.4
Thomas Colin
t.colin at i-optics.com
Fri Jan 10 11:28:07 CET 2014
Hi,
After migrating two applications from Windows 7 to Windows 8, I noticed this strange behavior:
1) Create an application that uses QLineEdit widgets
2) Set the background color to anything other than white, e.g. blue, using qt stylesheets
3) Run the application. The QLineEdit backgrounds are blue
4) Hover over the widget with the mouse. The QLineEdit backgrounds are now white
5) Wait a couple seconds for the widgets to get repainted. The QLineEdit backgrounds are back to blue.
I could reproduce this behavior with a minimal GUI application, so the bug appears to be with Windows 8, Qt 4.8.4, MinGW 4.4, and their combination, rather than a specific piece of "user" code. I tried to manually define a background color when hovering, but this only shows up after the white background was displayed and has "timed out". Note: if the widget background is not modified by a stylesheet, it is white by default; so the bug is not visible, although probably still occurring (optional question: is a GUI bug still "occurring" when nobody can see it?).
Example code for reproducing the bug (Windows 8 / Qt 4.8.4 / MinGW 4.4; occurs in both release and debug builds; also occurs for executables generated in Windows 7 but being run in Windows 8):
File - widgetbackgroundmainwindows.h
#ifndef WIDGETBACKGROUNDMAINWINDOW_H
#define WIDGETBACKGROUNDMAINWINDOW_H
#include <QMainWindow>
#include <QLineEdit>
#include <QVBoxLayout>
class WidgetBackgroundMainWindow : public QMainWindow
{
Q_OBJECT
public:
explicit WidgetBackgroundMainWindow(QWidget *parent = 0);
~WidgetBackgroundMainWindow();
private:
QLineEdit *m_lineEdit1;
QLineEdit *m_lineEdit2;
QVBoxLayout *m_layout;
QWidget *m_central;
};
#endif // WIDGETBACKGROUNDMAINWINDOW_H
File: widgetbackgroundmainwindow.cpp
#include "widgetbackgroundmainwindow.h"
#include "ui_widgetbackgroundmainwindow.h"
WidgetBackgroundMainWindow::WidgetBackgroundMainWindow(QWidget *parent) :
QMainWindow(parent)
{
m_central = new QWidget();
setCentralWidget(m_central);
m_layout = new QVBoxLayout();
m_central->setLayout(m_layout);
m_lineEdit1 = new QLineEdit();
m_lineEdit2 = new QLineEdit();
m_layout->addWidget(m_lineEdit1);
m_layout->addWidget(m_lineEdit2);
m_lineEdit1->setStyleSheet("background-color:#888888;");//grey
m_lineEdit2->setStyleSheet("background-color:#13579B;");//blue
}
WidgetBackgroundMainWindow::~WidgetBackgroundMainWindow()
{
}
Any help or ideas are much appreciated.
Kind regards,
Thomas COLIN
More information about the Interest
mailing list