简体   繁体   English

QListWidget项上面的PyQt5 cursor如何弹出WhatsThis文档?

[英]How PyQt5 cursor above QListWidget item pops WhatsThis documentation?

How to give a definition for each item in QListWidget, so that the cursor changes to WhatsThis Cursor and pops an doc of explication when the cursor is over it?如何为 QListWidget 中的每个项目提供定义,以便 cursor 更改为 WhatsThis Cursor 并在 cursor 超过它时弹出解释文档?

Something like this but for an item of QListWidget像这样的东西,但对于 QListWidget 的一项

在此处输入图像描述

I tried simply:我简单地尝试了:

for i, def in zip(range(self.listWidget.count()), some_doc):
    self.listWidget.item(i).setWhatsThis(def)

But the doc didn't show up但是医生没有出现

That appears to be the correct way to set the WhatsThis .这似乎是设置WhatsThis的正确方法。 However, you state that you want this to appear on hovering, which is instead the tooltip property.但是,您希望它出现在悬停时,这是工具提示属性。

solution:解决方案:

for i, def in zip(range(self.listWidget.count()), some_doc):
    self.listWidget.item(i).setToolTip(def)

If you want this behavior only in WhatsThis mode, you will have to subclass the QListWidgetItem and set the tooltip to only return when QtWidgets.QWhatsThis.inWhatsThisMode() is true.如果您只希望在 WhatsThis 模式下实现此行为,则必须继承 QListWidgetItem 并将工具提示设置为仅在QtWidgets.QWhatsThis.inWhatsThisMode()为真时返回。

If you really are just having problems with the WhatsThis property working on click, we will need to see more of your code and possibly a screenshot of your window.如果您真的只是在单击时遇到WhatsThis属性的问题,我们将需要查看更多代码,并且可能需要查看 window 的屏幕截图。 Because like I said, the loop at the beginning should work at just setting the normal property.因为就像我说的那样,一开始的循环应该只用于设置正常属性。

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

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