QLineEdit:hover { background: blue; } only changes color when it has focus
-
So my application has multiple QLineEdit widgets. These widgets are created inside my own custom class, which is derived from QWidget.
The constructor of my custom class is as following:setFixedSize(200,50); setAutoFillBackground(true); inputLine->setValidator(validator); inputLine->setMinimumSize(100,30); inputLine->setToolTip("hovering"); inputLine->setStyleSheet("QLineEdit:hover { background: blue; } QLineEdit { background: green;}");Inside the header file, the QLineEdit is created as following:
QLineEdit *inputLine = new QLineEdit(this);I would expect the inputLine to be green and when the mouse is hovering over the widget to turn blue, however this does not happen.

Also, the tooltip is also not appearing.
However, if I put focus onto one of the QLineEdit by clicking on it, it does give the tool tip and also turns the background to blue. Once I clicked one of the QLineEdit's it will give you the tooltip when hovering over other lines too.

Either this is a bug or I am not understanding how the QLineEdit:hover pseudo state works?
Any help will be appreciated.
Edit 1:
I came across QLineEdit. So I went to try this instead of QLineEdit and this is the result.

And this just works as I expected it to work with QLineEdit, so this makes me think even more it's a bug. Although this is a working alternative for me since I will mostly use it for numbers anyway, I am still not satisfied with why it's not working with QLineEdit. -
So I just tested it on Linux and on Linux the QLineEdit works the same as QSpinBox. So I guess its a bug for windows.
-
So I just tested it on Linux and on Linux the QLineEdit works the same as QSpinBox. So I guess its a bug for windows.
What exact Qt version and style do you use on windows?
-
What exact Qt version and style do you use on windows?
@Christian-Ehrlicher Hey, I use windows 11 and QT version 6.7.0. The style version I am not sure but its the latest stable.
-
So my application has multiple QLineEdit widgets. These widgets are created inside my own custom class, which is derived from QWidget.
The constructor of my custom class is as following:setFixedSize(200,50); setAutoFillBackground(true); inputLine->setValidator(validator); inputLine->setMinimumSize(100,30); inputLine->setToolTip("hovering"); inputLine->setStyleSheet("QLineEdit:hover { background: blue; } QLineEdit { background: green;}");Inside the header file, the QLineEdit is created as following:
QLineEdit *inputLine = new QLineEdit(this);I would expect the inputLine to be green and when the mouse is hovering over the widget to turn blue, however this does not happen.

Also, the tooltip is also not appearing.
However, if I put focus onto one of the QLineEdit by clicking on it, it does give the tool tip and also turns the background to blue. Once I clicked one of the QLineEdit's it will give you the tooltip when hovering over other lines too.

Either this is a bug or I am not understanding how the QLineEdit:hover pseudo state works?
Any help will be appreciated.
Edit 1:
I came across QLineEdit. So I went to try this instead of QLineEdit and this is the result.

And this just works as I expected it to work with QLineEdit, so this makes me think even more it's a bug. Although this is a working alternative for me since I will mostly use it for numbers anyway, I am still not satisfied with why it's not working with QLineEdit.@Mighty_Pig said in QLineEdit:hover { background: blue; } only changes color when it has focus:
QLineEdit
Correction: I came across QSpinBox not QLineEdit
-
@Mighty_Pig said in QLineEdit:hover { background: blue; } only changes color when it has focus:
QLineEdit
Correction: I came across QSpinBox not QLineEdit
Start your app with
-style windowsvistato use the windows 10 style instead the new windows 11 style which is new in qt6.7 and still has some problems. Pinging @Axel-Spoerl to see if this bug is already reported and maybe fixed. -
Start your app with
-style windowsvistato use the windows 10 style instead the new windows 11 style which is new in qt6.7 and still has some problems. Pinging @Axel-Spoerl to see if this bug is already reported and maybe fixed.@Christian-Ehrlicher
Doesn’t ring a bell here. Maybe worth reporting! -
@Christian-Ehrlicher
Doesn’t ring a bell here. Maybe worth reporting!@Axel-Spoerl I already made a bug report.
https://bugreports.qt.io/browse/QTBUG-124549 -
@Axel-Spoerl I already made a bug report.
https://bugreports.qt.io/browse/QTBUG-124549@Mighty_Pig
Very well, I’ll look into it then.