2024-09-26 18:19:06 发布
网友
我正在寻找以下功能:
self.ui.pushButton_connect2.click()
红十字按钮
你可以使用QTest,只需找到按钮的位置。只要用按钮所连接的方法替换keypressEvent
keypressEvent
from PyQt5.Qt import * class Window(QWidget): def __init__(self,parent=None): super(Window,self).__init__(parent) def keyPressEvent(self, QKeyEvent): if QKeyEvent.key() == Qt.Key_C: QTest.mousePress(self,Qt.LeftButton,Qt.KeyboardModifierMask,pos=QPoint(200,150)) def mousePressEvent(self, event): print(event.pos()) super().mousePressEvent(event) app = QApplication([]) w = Window() w.show() app.exit(app.exec_())`
你可以使用QTest,只需找到按钮的位置。只要用按钮所连接的方法替换
keypressEvent
相关问题 更多 >
编程相关推荐