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? -
Hi
That you can do with stylesheets
http://doc.qt.io/qt-5/stylesheet-syntax.html
and QStyle
http://doc.qt.io/qt-5/qstyle.htmlexample
http://thesmithfam.org/blog/2009/09/10/qt-stylesheets-tutorial/ -
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. -
-
I mean how do I access the form?
I tried:this->resize(500,600);
RepairDevices::resize(500,600);
ui.RepairDevices->resize(500,600);
The first two compile, but don't change the size of the window.
The third, does not compile.This is from Designer:
Hi
What ever RepairDevices is inside of, is the form.
MainWindow most likely
so that would beui->RepairDevices->resize
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:
this->setFixedSize(500, 600);
But the widgets on the form became black after resize!!
I guess it needs something like this->refresh.
Is there something like that? -
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.
-
Also works this:
this->setMinimumSize(500,600); this->setMaximumSize(500,600);
But the widgets also don't refresh.
Is there some way to force them redraw? -
@Panoss
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.
http://doc.qt.io/qt-5/designer-layouts.html -
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.@Panoss
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.