简体   繁体   English

PyQt5将QMainWindow作为第一个窗口

[英]PyQt5 Focus QMainWindow as first window

I am building an application in pyqt, which is called by another application with another graphical interface not built in pyqt. 我正在pyqt中构建一个应用程序,它由另一个应用程序调用,另一个应用程序使用另一个不在pyqt中构建的图形界面。 I have a QMainWindow, the problem is that when the boot appears behind the other application, and I do not know how to make it appear with the focus. 我有一个QMainWindow,问题是当引导出现在其他应用程序后面时,我不知道如何让它出现在焦点上。 I try to pass window type in a constructor 我尝试在构造函数中传递窗口类型

Qt_WindowType

But does not work 但是不起作用

This is my class 这是我的班级

class Foo(QMainWindow):
    def __init__(self, logger):
        super(Foo, self).__init__()
        # more code...
        self.show()

if __name__ == '__main__':
    app = QApplication(sys.argv)
    ex = ScanGui(logger)
    sys.exit(app.exec_())

Thx. 谢谢。

Depending on what you are exactly looking for I'd say to have a look in this flag: 根据你正在寻找的东西,我要说看看这面旗帜:

self.setWindowFlags(Qt.WindowStaysOnTopHint)

You can also make use of Modal modality. 您还可以使用模态模态。

SetWindowModality instead of WindowStayOnTopHint, and both modal modes (Qt.WindowModal and Qt.ApplicationModal) permit other applications to be on top of your modal window. SetWindowModality而不是WindowStayOnTopHint,两种模态模式 (Qt.WindowModal和Qt.ApplicationModal)允许其他应用程序位于模态窗口之上。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM