Solved Blinking background
-
Hi
Nope even with your new test code
and full screen window size i dont get that effect.Could you try
label1->setAutoFillBackground(false); label2->setAutoFillBackground(false); label3->setAutoFillBackground(false);
inside myWidget ?
Should be off but just to be sure. -
@mrjj, I don't know how it was set originally, but adding "setAutoFillBackground" changes nothing :/
Edit: I ran this app on another computer and it's visible there too. -
@Corvette653
Hi
Ok, was the only thing i could think of.Im not sure what you see.
If you move mouse more slowly, does it also happen ? -
@mrjj
Me neither.
When I move mouse very slow, everything is alright.
How often is it checked if mouse is over widget?
Is it possible that it happens when I move mouse: label -> out of widget,
but if I move: margin -> out of widget, everything is ok? -
@Corvette653
Hi
I think on every mouse move event as to check its still over it.
Well both the main Widget and the Labels are affected by your stylesheet but
Labels are transparent so not sure it would do so much.But yes from the video , it does seem related to the labels background as the
white ghost thing seems to be where the labels are. -
:/ It's strange, I wanted to change font color, of the whole widget(3 labels), but it doesn't work in the way I want
setStyleSheet(":hover{background-color: red; color: white;}");
-
Hi
What happens ? -
Only label I directly hover has the white text, I want the whole widget to has.
Background color is set in the same line, but works good (except that strange white ghosts which I have already ignored) -
@Corvette653
Well that is kinda to be expected as only one widget is actually "hovered" at a given time.
You do see the red all over as labels are transparent so we see the master widget in red under it.You could add the function to class MyWidget : public QWidget
to handle hover directly and in there then set style sheet to master widget to turn red and
then set style sheet to each label to turn white at same time.in ctor this->setAttribute(Qt::WA_HOVER, true); void MyWidget ::enterEvent(QEvent * event) { // set style sheet QWidget::enterEvent(event); } void MyWidget ::leaveEvent(QEvent * event) { // other style sheet to return to nomral color for text QWidget::leaveEvent(event); }
https://stackoverflow.com/questions/411823/how-do-i-implement-qhoverevent-in-qt
-
@mrjj
Maybe it's not exactly answear to first question, but it resolves that.
I moved bckground-color to those functions and it works correctly -
@Corvette653
Hi
well it's not really possible to hover more than one widget at a time so
pure style sheet would not be able to make all labels use white on hover.