pyqt5悬停在qpushbutton上,鼠标压向下
我正在尝试使用QT按钮而不是像素模拟油漆刷。我在每个按钮上都超载了事件过滤器,只有在未按下鼠标时,才能检测到事件持续或事件窗口。我想按住鼠标单击并检测是否与按钮相撞。关于我应该从这里做什么的建议?
def eventFilter(self, a0, a1):
if a1.type() == QtCore.QEvent.Enter:
if(self.mouse.pressed):
ui_logic.square_press(self,"red")
return super().eventFilter(a0, a1)
def square_press(button,color):
style = "QPushButton{background-color:" + color + "}"
button.setStyleSheet(style)
谢谢
I am trying to simulate a paint brush with Qt buttons instead of pixels. I have overloaded the event filter on each button and can detect eventHover or eventFilter only when the mouse is not pressed down. I want to hold mouse click down and detect if i collide with a button. Any suggestions as to what i should do from here?
def eventFilter(self, a0, a1):
if a1.type() == QtCore.QEvent.Enter:
if(self.mouse.pressed):
ui_logic.square_press(self,"red")
return super().eventFilter(a0, a1)
def square_press(button,color):
style = "QPushButton{background-color:" + color + "}"
button.setStyleSheet(style)
Thank you
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我最终做的是跟踪鼠标并将小部件放在一个位置。
示例代码:
What i ended up doing is tracking the mouse and getting the widget at a location.
Example code: