How to hover over a label to display text
-
@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[1])
. 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.self.ui.label_83.setToolTip(str(person[1]))
-
@LT-K101
Since there are many examples on the web of usingsetToolTip()
on aQLabel
I don't know what to say. If you leave your labels namedlabel_83
it'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[1]))
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
QLabel
which you are probably not set up for. In any case it still usesQLabel::setToolTip()
.