如何使用“?”在QDialog窗口平铺栏上?

时间:2018-10-11 00:39:33

标签: python pyqt pyqt5 qt-designer

使用QT Designer通过QDialog生成的窗口中有一个“?”窗口标题栏上的按钮。您如何将此按钮连接到显示帮助信息的html文件?我希望QT Designer中会有一个引用“?”的对象。按钮,但是我找不到它。

enter image description here

1 个答案:

答案 0 :(得分:0)

我不明白为什么要使用按钮,但是如果要检测单击事件并假设您在Windows中,则可能的解决方案是使用nativeEvent()方法,因为该元素取决于每个平台:

import ctypes.wintypes
import win32con
from  PyQt5 import QtWidgets


class Dialog(QtWidgets.QDialog):
    def nativeEvent(self, eventType, message):
        msg = ctypes.wintypes.MSG.from_address(message.__int__())
        if eventType == "windows_generic_MSG":
            if msg.message == win32con.WM_NCLBUTTONDOWN:
                print("Hello World")
        return super(Dialog, self).nativeEvent(eventType, message)


if __name__ == '__main__':
    import sys
    app = QtWidgets.QApplication(sys.argv)
    w = Dialog()
    w.exec_()
相关问题