Python中文
首页
教程
问答
标签
搜索
登录
注册
Pyqt QgraphicsItem context menu overriden by QGraphicsView contextmenu
回答此问题可获得
20
贡献值,回答如果被采纳可获得
50
分。
<p>我在一个经典的QgraphicsView/qgraphicscene/QGraphicsItem框架中工作。 我在QgraphicsView中声明一个上下文菜单:</p> <pre><code> self.setContextMenuPolicy(QtCore.Qt.CustomContextMenu) self.customContextMenuRequested.connect(self.__contextMenu) </code></pre> <p>后来:</p> ^{pr2}$ <p>然后在QGraphicsItem实例类中,我使用contextMenuEvent,如下所示:</p> <pre><code># --------------------------------------------------------------------------- def contextMenuEvent(self, event): """ """ # ----> Creating Context menu ----------------------------------- oTreeMenu = QtGui.QMenu() </code></pre> <p>问题是QGraphicsItem事件被QGraphicsView完全覆盖。 我该如何处理这两个问题?在</p>
0 条评论
分类:
Python问答
请先
登录
后评论
默认排序
时间排序
1 个回答
匿名
1天前
擅长:python、mysql、java
<p>我找到了一个解决方案:</p> <p>我使用的是qgraphicsceneContextMenuEvent,而不是另外两个。 在事件中,我检查鼠标是否在QGraphicsItem上方,并构建相应的菜单。在</p> <p>我真的不喜欢这个解决方案,因为我所有的函数都在qgraphicscene类下,而且大多数函数都与项目有关,而不是场景。所以这有点乱,但是很管用。在</p> <p>还是希望看到更好的解决方案。在</p>
请先
登录
后评论
针对此问题:
更多的回答
关注
89
关注
收藏
1
收藏,
216
浏览
网友 提问于 2天前
相关Python问题
在python3中使用Scipy pearsonr函数
6 回答
在Python3中使用scipy对多个lorentzian进行数据拟合
8 回答
在Python3中使用Script=argv
10 回答
在python3中使用selenium webdriver进行未解析的回溯
8 回答
在python3中使用selenium和phantomjs的网页截图之前如何等待?
4 回答
在Python3中使用Selenium和Requests模块从网页获取文件
8 回答
在python3中使用SIGINT终止函数
4 回答
在Python3中使用SIGTERM时,允许进程完成而不是中断
3 回答
在python3中使用smtplib发送XML内容
6 回答
在python3中使用socket库(RFCOMM模式)重新连接蓝牙设备?
6 回答
在python3中使用sounddevice和numpy编写wav文件
6 回答
在python3中使用Sqlalchemy插入MySQL查找类型错误的原因
4 回答
在python3中使用sqlite、pandas和sqlalchemy很难让rollback工作
2 回答
在python3中使用SQLite的FTS3/4
2 回答
在Python3中使用struct.calcsize()和len()有区别吗?
7 回答
在python3中使用substring函数时发生TypeError
9 回答
在Python3中使用Tkinter entry小部件写入串行设备
2 回答
在python3中使用tkinter时,如何在每次按下函数时获得运行该函数的按钮?
6 回答
在python3中使用tkinter的子帧
4 回答
在Python3中使用tryexcept块时,如何避免使用未初始化的变量?
4 回答