简体   繁体   中英

How can I set member property as tooltip for QGraphicsItem?

I set the item name as the tooltip for QGraphicsItem by default. But in my program, users can change this item name, so I want to show the correct tooltip after they change the name. But setToolTip() only accept const QString, is there any way to accept a dynamic changing member property as input?

I do not want to just use setToolTip(QString) everytime user change the item name, since I may include many other member properties into the tooltip, not just the name. Thank you!

Sice you can always get the updated item name, you can add a signal which gets emitted whenever there is a change in the item name and connect this signal with a slot which can be used to set the tooltip to the updated item name along with other member properties you would like to set it to.

Hope this helps.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM