Hover image

I am wondering if there is a simple and quick way to display the image when the user hovers over QLabel ...

Since QLabel can be used to display QPixmap, I would like to display some kind of "preview" when QLabel hangs ...

Do you guys know how I can do this?

Thanks in advance!

+3
source share
3 answers

You can set a tooltip for using html, including tags <img>. Will this do what you need?

docs, , - , . (, )

, ... . ?

+6

, , jkerian:

:

MyLabel->setToolTip("<html><img src="+MyImagePathAsString+"/></html>");

:

alt text

jkerian.

+5

I don’t know what layout your QLabel is in, but I assume that this will lead to strange layout changes if you just set the pixmap on the label when you hover over it. Most likely, use the tooltip or just show pixmap freely on the canvas.

0
source

Source: https://habr.com/ru/post/1763660/


All Articles