Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
How to easilly add a second 'skin' to my app
In my app I want to add a second 'skin', a second look.
The one I have now is the 'combact', in which all widget are small and very close one to the other.
I want to add another one, which will be swithed by a QPushButton.
Ok, I can do it with widget.resize(width, height) but it would be a lot of code and a lot of calculations.
I was thinking, could I simply make a second ui and load this on the QPushButton 's click slot?
Is this possible?
How do I set the size of my ui (of my form)? (in a slot)
It's a QWidget, with minimumSize and maximumSize set from within the Qt Designer.
you can use setGeometry or resize.
I mean how do I access the form?
The first two compile, but don't change the size of the window.
The third, does not compile.
This is from Designer:
What ever RepairDevices is inside of, is the form.
MainWindow most likely
so that would be
unless in a layout of course.
The form is the Mainwindow. RepairDevices is not the form. ( it seems not)
Only this works, everything else fails:
But the widgets on the form became black after resize!!
I guess it needs something like this->refresh.
Is there something like that?
ok but what are you trying ?
No, you do not need refresh()
They should redraw by themself.
The "this->setGeometry(0,0,500,500);" only moves it on the top left corner. Doesn't resize.
Maybe because I have minmumSize and maximumSize set in the Designer.
They don't redraw by themself.
Well if u set fixed size, that is 100% what you get. :)
Also works this:
But the widgets also don't refresh.
Is there some way to force them redraw?
Its never, ever need to ask them to refresh when resizing the form.
Something else is wrong.
Did you use layouts at all ? so resize mainwindow will resize the widgets?
No I don't use any layouts at all.
well then resizing the main form will do absolutely nothing to the
widgets in the form. should remain same place and not move/resize at all.
If they go black, i wonder if you tried to resize some yourself from a resize event or something like that.
it can lead to infinite loops :)
Else I am out of idea why they go black.
The right way is to use layouts.
I didn't resize any widget, only the form.
The reason I didn't use layouts is because they looked to me very complicated.
I 'll give it a try.
well if you want the widget to become bigger or smaller depending on the size of the window
then you must use layouts.
Else they wont.
So it depends on what your goal is.
Yes using layouts takes some practice but the rewards are great.