Details
-
Bug
-
Resolution: Unresolved
-
P2: Important
-
None
-
6.8, 6.9
-
None
Description
Description
On Windows, calling showMaximized() on a window does not reliably maximize the window to fill the screen. This appears to be due to interference from Windows Snap Assist, which attempts to arrange windows in a tiled layout rather than respecting the application's request for maximization.
Environment
Operating System: Windows 10/11
Qt Version: 6.8.x (via PySide6)
Python Version: 3.13
Steps to Reproduce
- Create a simple Qt6/PySide6 application with a main window on Windows 10 or 11
- Call window.showMaximized() to display the window
- Observe that the window is not maximized but instead appears in a non-maximized state
Expected Behavior
The window should appear maximized, filling the available screen space (except for the taskbar).
Actual Behavior
The window appears in a non-maximized state. Windows Snap Assist seems to be interfering with the maximization request, causing Qt to show the window in a standard or partially-sized state.
Code to Reproduce
from PySide6.QtWidgets import QApplication, QMainWindow, QPushButton, QVBoxLayout, QWidget class MainWindow(QMainWindow): def __init__(self): super().__init__() self.setWindowTitle("Maximization Test") # Create a central widget with some content central_widget = QWidget() layout = QVBoxLayout(central_widget) layout.addWidget(QPushButton("Test Button")) self.setCentralWidget(central_widget) def main(): app = QApplication() window = MainWindow() # This should maximize the window, but fails to do so reliably on Windows window.showMaximized() return app.exec() if __name__ == "__main__": sys.exit(main())
Attempted Workarounds
Several workarounds have been attempted, including:
- Calling show() before showMaximized()
- Using setWindowState(Qt.WindowState.WindowMaximized)
- Explicitly setting geometry to match screen size
- Using QTimer.singleShot() to delay the maximize call
While some of these approaches improve the situation in specific scenarios, none provide a consistent solution across all Windows environments.
Impact
This issue affects any Qt6/PySide6 application that needs to display maximized windows on startup on Windows platforms. We, the developers, are forced to implement complex platform-specific workarounds for what should be a simple and reliable operation.
Additional Context
The issue appears to be specifically related to how Windows Snap Assist interacts with window creation and maximization requests. This behavior doesn't occur on other platforms like Linux or macOS, where showMaximized() works as expected.