Reputation: 177
Currently I am trying to style QMainWindow using qss stylesheets. It works well, except of setting the size. I am using following qss params: width, height, min-width, min-height. max-width, max-height in the stylesheet file. Unfortunately no matter what I do, I cannot force the window to be less than 200x100 px. In the ui form properties such as geometry, sizePolicy, minimumSize and maximumSize are not defined, since I want to style it entirely using qss files. I would appreciate any hints :-)
Upvotes: 0
Views: 784
Reputation: 3535
As a note: if you want to define the whole UI/style in a separate UI/style file I would advise to check QML and QtQuick. For traditional QWidget applications we've tried to use Qt Style Sheet as much as we could but we've always hit some limitations (like you cannot set size-policy from a Qt Style Sheet).
If your project is not mission-critical I suggest to try QML. It's not as mature as the QWidget solution but it will improve a lot in the near future (especially with Qt5). If QML is not an option then you will probably have to set some parameters in code / QtDesigner from time-to-time.
Also there're some known issues with QWidget + Qt Style Sheet, like the Mac OS X QAbstractButton size problem (ex: QAbstractButton style sheet issue - to solve this one you either have to modify Qt source code or set the button's setFlat() parameter).
Upvotes: 0
Reputation: 3094
Set your minimumsize of window to 0.
window->setMinimumSize(QSize(0,0));
And also set maximum size of window to a big value, (1000,1000) would do.
window->setMaximumSize(QSize(1000,1000));
Set this property in your form(ui). Or in the constructor as above.
Now you can set any size you wish in css
, Considering the fact that a minimum 0 size and maximum 1000 size will give you the freedom to set almost any value practically
.
Upvotes: 1