Search code examples
pythonwindows-10pyqt5maximize-window

Is there a function that allows PyQt5 to open two windows that fill the entire screen?


I'm working with PyQt5 and I'd like to have my ui open on the left half of the screen with a PDF viewer (like foxit or adobe reader) on the right side of the screen. I know that maximize() will cause one window to fill the entire screen. Also, I know that I could open the two windows using exact pixel locations and that would work for most screen. However, is there a function that would 'snap' my PyQt application and a pdf viewer side by side for easy reading?

I'm working on windows 10


Solution

  • There is no method as specific as the one you require, the solution is to establish the geometry using the existing methods:

    # ...
    r = QGuiApplication.primaryScreen().geometry()
    r.setSize(QSize(0.5 * r.width(), r.height()))
    your_window.setGeometry(r)
    # ...