简体   繁体   English

如何将成员属性设置为 QGraphicsItem 的工具提示?

[英]How can I set member property as tooltip for QGraphicsItem?

I set the item name as the tooltip for QGraphicsItem by default.默认情况下,我将项目名称设置为 QGraphicsItem 的工具提示。 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?但是 setToolTip() 只接受 const QString,有没有办法接受动态变化的成员属性作为输入?

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.我不想在每次用户更改项目名称时都使用 setToolTip(QString),因为我可能会在工具提示中包含许多其他成员属性,而不仅仅是名称。 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.希望这可以帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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