Detecting Monitor Resolution Change and Resizing Child Widget
-
Hi everyone,
I'm facing an issue with resizing a child widget when my main application window is moved between monitors with different resolutions.
Scenario:
I have a main window with a toolbar and a main content area.
When a toolbar button is clicked, a child widget (a game) is shown, overlayed on the main content area.
The game widget has a fixed width but its height should adjust to the main window's height.Problem:
When I move the main window to a monitor with a different resolution, the game widget doesn't resize correctly. It seems the resizeEvent is not triggered reliably when switching monitors.
Current Approach:
I'm currently handling the resizeEvent to adjust the game widget's height.
I've also tried using moveEvent to force a resize when the window moves, but it doesn't seem to be the most efficient solution.Question:
Is there a better way to detect changes in monitor resolution and trigger a resize of the child widget accordingly?
I'm looking for a more robust and efficient solution than relying solely on resizeEvent or moveEvent.
Any suggestions or insights would be greatly appreciated!Thanks,
Franco -
Moving a window between places on the desktop, whether on the same screen or not, does not change the size of the widget in pixels. I would not expect a resize event unless the widget is actually resized.
When a toolbar button is clicked, a child widget (a game) is shown, overlayed on the main content area.
The game widget has a fixed width but its height should adjust to the main window's height.You have opted to manually (place and) resize items that can be automatically resized. Is there a reason that the game panel is not part of the main content area layout? It could either be the main content area itself, be part of a layout that fills the main content area, or a page in a QStackedWidget that is a switched in or out as required.
-
Yes, it cannot be part of the layout of the main window area because the widget I have to render on top of it is semi translucent and the widgets below should be visible at the same time. Also the main window' widgets can not be moved when the game widget is shown. I don't use a stacked widget because the size between the game widget and the main window central widget is much different. That's why I render it on top of the main window and I manually resize it