PDA

View Full Version : enable mousetracking vs stylesheet hover



Ini
15th May 2016, 16:17
Hello,

i would need like two background-images on one QLabel while hover. It seems thats not possible in qt, so I need two lets say Qlabels on top of each other. Now i cannot use hover-stylesheets on the bottom QLabel. So I am thinking about to enable mousetracking. Does this eat much resources im comparison to the stylesheet-hover-effects?

(Making one image out of the two would be bad for the workflow if there are changes to make)

thanks

anda_skoa
15th May 2016, 17:08
Is "button" referring to some custom component made from two labels?
In which case wouldn't it be easier to just swap the pixmap on a single label?

Or do you mean showing a series of images while hovering? E.g. like an animation?

Cheers,
_

Ini
15th May 2016, 18:05
Sry button is QLabel i did edit that. As I said it's very bad for the workflow to use one image on one QLabel, if there are changes to make. Lets's say I have like 2 QLabels on top of each other and this 10 times and every bottom-QLabel has the same image and every top-QLabel has different images. I have to change the image on every QLabel on the bottom now. Quite easy. If it would be one image on one QLabel instead of two stacked QLabels with seperate images, I would have to make 10 changes. Pretty bad. Thats why.

No animation just hover.

I am asking just for performance-comparision. I dont know why this information is important ;). Anyway I provided and example, maybe I should leave that next time at the first post.

anda_skoa
16th May 2016, 08:40
As I said it's very bad for the workflow to use one image on one QLabel, if there are changes to make.

Not sure I understand what you mean but even if a widget is displaying a single image, that image can be composed from many sources.



Lets's say I have like 2 QLabels on top of each other and this 10 times and every bottom-QLabel has the same image and every top-QLabel has different images.

Ok, 10 instances of a custom component made from two labels.



I have to change the image on every QLabel on the bottom now. Quite easy.

Indeed



If it would be one image on one QLabel instead of two stacked QLabels with seperate images, I would have to make 10 changes. Pretty bad. Thats why.

You always need to tell 10 objects to make a change, no?



I am asking just for performance-comparision. I dont know why this information is important ;). Anyway I provided and example, maybe I should leave that next time at the first post.
Well, mouse tracking will lead to mouse move events sent to the widget that has it enabled.
If it doesn't do anything with the event then the overhead should be negligible.

But I don't think you need mouse tracking for simple hover, only when you need to know where the mouse is inside the widget.
Inside/outside should be determinable by overwriting enterEvent() and leaveEvent().

Cheers,
_