【发布时间】:2018-07-27 12:09:20
【问题描述】:
在 PyQt5 中,我可以使用以下方法更改对象的光标:
Object.setCursor(QCursor(Qt.PointingHandCursor))
对于其他按钮,我使用此类,但它不会更改 QmessageBox 或 Qfiledialog 中的光标:
class QPushButton(QPushButton):
def __init__(self, parent=None):
super(QPushButton, self).__init__(parent)
self.setCursor(QCursor(Qt.PointingHandCursor))
如何更改QMessageBox 和QFileDialog 中所有按钮的光标?
消息框方法示例
def onNotConnected(self):
err = QMessageBox.question(
self, DONGLE_NOT_CONN, DONGLE_NOT_CONN_MSG, QMessageBox.Ok | QMessageBox.Cancel)
if err == QMessageBox.Ok:
self.updating_thread(self.device_code)
else:
self.restart_program()
【问题讨论】:
-
QMessageBox 有 setCursor() 方法。
-
你指的是 QMessageBox 的静态方法吗,你可以解释一下。
-
QFileDialog 也有 setCursor() 方法。
-
你认为从一个类继承到另一个同名的类是正确的吗?
-
它们正在改变,因为您的 QPushButtons 不是原来的 QPushButtons,而是您在 python 中构建它们,而是 QMessageBox 和 QFileDialog 的静态方法是在 C++ 中创建的
标签: python python-3.x pyqt pyqt5 qmessagebox