工具提示或状态栏在 Maya 的 PyQt 应用程序中不起作用
我有一个 PyQt4 QDialog,我正在 Autodesk Maya 中从 python 启动它。我想在窗口中有一个状态栏,或者如果需要的话,有工具提示。玛雅似乎也不同意。我已经使用此处描述的方法实现了它:
http://www.qtcentre.org/ threads/10593-QDialog-StatusBar
如果我独立启动我的应用程序,则两者都可以正常工作。不过,从 Maya 运行时,状态更新会发送到常规 Maya 状态栏(如果您在不同的窗口中,这不是很明显),并且 Maya 似乎完全从我那里窃取了事件:如果我监视我的 event() 方法正在获取,它永远不会获取 QEvent.StatusTip 事件。我尝试将 QDialog 替换为 QMainWindow,但它似乎没有改变任何东西。
对于让这项工作发挥作用的途径有什么建议吗?
I've got a PyQt4 QDialog that I'm launching from python in Autodesk Maya. I want to have a status bar in the window or, if need be, tooltips. Maya doesn't seem to approve of either. I've implemented it using the method described here:
http://www.qtcentre.org/threads/10593-QDialog-StatusBar
If I launch my app standalone, both work correctly. Running from Maya, though, the status updates get sent to the general Maya status bar (which is not very obvious if you're in a different window), and Maya seems to steal the events completely from me: if I monitor the events that my event() method is getting, it never gets a QEvent.StatusTip event. I've tried swapping my QDialog for a QMainWindow, but it doesn't seem to change anything.
Any suggestions for avenues to look down to get this working?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
目前,我正在以一种可怕的方式解决这个问题:对我想要使用的每个小部件进行子类化,并添加一个要发送到父级的信号,
self.setMouseTracking(True)
和一个mouseMoveEvent(self, e)
将信号发送给父级。然后在树的顶部设置状态栏。这是一种令人讨厌的代码,让我感觉很肮脏,子类化了所有的小部件类型,但它似乎确实有效。任何更好的建议非常感谢!
At the moment, I'm working around this in a horrible way: subclassing each of widgets I want to use, and adding a signal to send to the parent,
self.setMouseTracking(True)
, and amouseMoveEvent(self, e)
that sends the signal to the parent. Then at the top of the tree I set the status bar. It's the sort of nasty code that makes me feel dirty, subclassing all the widget types, but it does seem to be working.Any better suggestions VERY gratefully received!
我也需要解决这个问题,所以你的帖子非常有帮助。
当我之前遇到类似的事件问题时,我通过在所有小部件(相同的过滤器)上使用 installEventFilter 来解决它,而不是子类化。然后您可以接收并接受事件以阻止它们从 Maya 进入(或让它们通过,例如用于在 gui 上标记菜单的空格键等)
这是我用来让 Maya 具有空格键(标记菜单)的方法,ctrl+A (属性编辑器切换)和 ctrl+Z(撤消)。这将被添加到您的事件过滤器中:
您只需要执行相反的操作并使用
event.accept()
和return False
I need to tackle this as well, so your post was quite helpful.
When I have encountered event issues like this before, I solved it by using installEventFilter on all widgets (the same filter), rather than subclassing. Then you can receive and accept the events to block them from Maya (or let them through, e.g. space bar for marking menus over your gui, etc)
Here is what I use to let Maya have the spacebar (marking menus), ctrl+A (attribute editor toggle) and ctrl+Z (undo). This would be added to your event filter:
You would just need to do the opposite and use
event.accept()
andreturn False
对于 QWidgets,这里的 colts 答案 非常好。
这就是我让它为 QActions 工作的方法:
然后在创建操作后:
我希望这会有所帮助。
For QWidgets, colts answer here is pretty good.
This is how I got it working for QActions:
Then after the action is created:
I hope this helps.