开发者

Which button was clicked?

开发者 https://www.devze.com 2022-12-29 17:48 出处:网络
How can I detect which mouse button was clicked (right or left) in the slot for QtCore.SIGNAL(\'cellClicked(int,开发者_开发知识库int)\')?You would probably pass the event to your cellClicked function.

How can I detect which mouse button was clicked (right or left) in the slot for QtCore.SIGNAL('cellClicked(int,开发者_开发知识库int)')?


You would probably pass the event to your cellClicked function. I'm assuming you emit your signal from a place that has access to a QMouseEvent.

Check out this thread.

Excerpt:

def mousePressEvent(self, event):
    if event.button() == QtCore.Qt.RightButton:
        event.accept()
        self.rightClickMenu(event)
    else:
        event.ignore()

Also, this mailing list thread looks like a more complete example.

0

精彩评论

暂无评论...
验证码 换一张
取 消