Unsolved Screen resolution and scalability
-
Hi all,
I'm new here and very excited to join you guys, i wanted to know if there is a way to scale or set aspect ratios to scale my window with
different screen sizes like the 15, 10 and 7 inches screens without having to write one for each size of screens?? -
@Edward_Abdelsayed
Hi and welcome :)
To make widgets automatically adjust size , you use layouts.
http://doc.qt.io/qt-5/layout.htmlYou can do it visually in Designer
http://doc.qt.io/qt-5/designer-layouts.htmlOverall, you define how they should scale. like minimum size and max size etc.
It takes a little bit to learn, but then you get scaling almost free. -
Thank you @mrjj is there a way to do it in Qt 4
-
@Edward_Abdelsayed
Hi
Yes its 100% the same :)
http://doc.qt.io/qt-4.8/designer-layouts.html -
@mrjj Is this solution applicable in the following context?
I made a Qt C++ Desktop application for Windows 10 (Visual Studio 2015): on the initial computer (2880x1800) the layout is very nice but for the second (1680x1050) all is wonky:- spacing between widgets is all wrong
- tables put lots of extra white space after columns (only 3 input columns)
- buttons at bottom of window no longer show-up...
Thanks.!
-
@RingAndReed
Yes, sounds like you need a layout.
Did you use any layout?Update:
for the table , there is a function to make it use all space for the cells. its not layout related.view->horizontalHeader()->setStretchLastSection(true) to make the last column expand to free space.
view->horizontalHeader()->setResizeMode(QHeaderView::Stretch) to give columns the same width. -
@mrjj : no I did not ... I am very new to Qt C++.
I think, you answered before I edited my question (added 2 screenshots).
I will try the layouts as you suggest. Right now, I did not even account for scrollbars etc.
-
@RingAndReed
Then you surely need at least one to make them fit mainwindow.
Also note the update regarding the table.Note2: in Designer, it shows layouts with the buttons/widgets in the left side.
Those are not the ones to use :)Right click and use the layout menu to apply layout.
Its a little bit hard at first so prepare to practice a bit.
There are many videos of using them.Note3:
To control if stuff get to small or too big,, you use
the MinimumSize and MaximumSize. Layout respect that.
You can also set policy telling if u want to be small as possible, use all space or how it should be.