Widget does not move when Main Window is resized.
i am new to Qt and i am struggling with resizing things , i managed to resize my background image according to the Main Window , now i'm trying to properly position my widget when Main Window is resized.
I want the widget to be positioned in the right place when the Main Window is resized , however , my widget stays in the same place when window is resized .I tried layouts , but layout does not work in my case as it expands the widget according to the Main Window.
i want the widget to be of the same size but be positioned properly when window is resized or maximized.
Thanks in advance :)
Hi and welcome
Layouts is normally the way to do such things.
You can set Maximum/minimum size on your widget to prevent the layout
from changing the size even when mainwindow get bigger.
Alternativ you can override (for main win)
and simply reposition the widget. ( dont use layout in this case)
Hi thanks for the reply.
Can you tell me how to set the maximum/minimum size on widget. Sorry i'm a beginner.
And will that solve my problem.?
My problem is when my window is of normal size, the widget is at the right side , but when i maximize my window my widget stays in the same position on the screen . So when i maximize it , the widget is seen at the center of the window as it stays in the same position.
I want the widget to be at the right when i maximize the window.
Hope you understand my problem :)
you can set in as a property in the right side of designer.
(select widget first)
you can also do it from code with
like in mainwindow constructor after setupUI()
something like this ?
My problem is when my window is of normal size, the widget is at the right side , but when i maximize my window my widget stays in the same position on the screen .
Your main window's central widget has no layout, so your widget is just floating around. Set a layout for the central widget, set the size policy of the widget to Fixed in the designer (the property pane when you select the widget) and set the sizes of the widget in the designer (again the property pane on the right).