Unsolved How to hover over a label to display text
Hi, Please I'm really struggling on how to hover over a label to display text. I have seen some tutorials on how to hover over a pushButton to change background color. Any assistance will be appreciated. Thanks in advance.
JonB last edited by
What do you actually mean by "hover over a label to display text."? You can just call
QLabel::setToolTip("Some text")to display text when hovering.
@JonB I tried the code below and it returns an empty toolTip with no message.
self.ui.label_83.setToolTip("Name: Jane " )
What I actaully want to achieve is when I hover on a profile image the name of the person should be displayed from database. I can see the name from database with
print(person). However when I tried the syntax below I get an empty toolTip when I hover over the label containing the image. I think I might be doing something wrong.
JonB last edited by JonB
Since there are many examples on the web of using
QLabelI don't know what to say. If you leave your labels named
label_83it's hardly to easy to verify which one you are setting it on....
You can/must set the tooltip which comes from a database at the time the correct data is available. For your
setToolTip(str(person))I don't know when that is, but you do.
An alternative approach to set a dynamic tooltip, i.e. one whose text is not set/evaluated until the time the user hovers instead of in advance, is shown in https://stackoverflow.com/a/21869703, but they may require subclassing
QLabelwhich you are probably not set up for. In any case it still uses