PDA

View Full Version : Resize application for different resolutions



Mrdata
24th January 2008, 21:21
I've this QT program i made working ok for the current pc resolution i'm using, 1280x1024
When i switched the resolution to 1024x768 and 800x600 i noticed that application was a display mess, with several things being cut off from the screen, very large widgets,etc
I searched the QT help and forum and noticed the sizehint function and Qdesktopwidget could be possible solutions for it, but at the moment i'm confused in how to use them properly to solve my problem

With Qdesktopwidget i can retrieve current screen resolution but this means that i have to resize and position "manually" all my widgets (which includes qlinedits, comboboxs,buttons, setspacings, etc) to behave accordingly to the one of the 3 resolutions, there's isn't a simplier way to do such thing? Thanks

wysota
24th January 2008, 21:40
Did you remember to put all the widgets into a layout?

Mrdata
24th January 2008, 22:41
Yes, all of my widgets are inside a QGridLayout

wysota
25th January 2008, 00:19
Then maybe you are changing minimum or maximum sizes of widgets? Otherwise the only explanation is that you have so many widgets they simply won't fit the screen even if resized to minimum and there isn't much you can do about it - the only way is to relayout them differently.

Mrdata
25th January 2008, 00:46
Well, indeed i had several setMaximumWidth and setMinimumWidth for the widgets, i removed all of them and also reduced the font size ( i was using bold 10, changed it to normal 8), it helped a bit but it still have lot's of cutting at the bottom of the window. Maybe i'm indeed using too much widgets... Curious thing is that i'm almost cloning a similar program (don't know which language or program they used to make it), but in that program with the exactly same amount of widgets on screen (and same sizes), things work great between different resolutions. I'll now take a another look at all widgets to see how to sort this thing out :confused:

wysota
25th January 2008, 09:08
Could you attach the UI file here? I'd like to take a look at it.

Mrdata
25th January 2008, 15:16
Actually i'm not using any UI file in my application, i've choosed not to use it (can the problem be here? )
I'll take another look at this, and if i don't solve it today I'll try to clean the code and send
the source code file to you. Thanks.

wysota
25th January 2008, 15:23
In that case attach the code you use to create the user interface.

Mrdata
25th January 2008, 16:18
Here's how i initialize my application




Mainwindow = new QWidget;
setCentralWidget( Mainwindow );
Mainwindow->showMaximized();

Top_GroupBox = new QGroupBox( tr( "Group 1" ) );
QGridLayout *MyLayout1 = new QGridLayout;

.......
MyLayout1->addWidget( Label1, 1, 0, Qt::AlignRight );
MyLayout1->addWidget( LineEdit1, 1, 1, Qt::AlignLeft );
.......
Top_GroupBox->setLayout( MyLayout1 );

// create 2 more Qgridlayouts here
.....
// add all 3 Qgridlayouts to the mainwindow
.....

wysota
25th January 2008, 17:43
It'd be nice if you also provided the contents of the layouts and the call to setLayout on Mainwindow.