JacquesBaniaque
19th June 2010, 14:11
Hi,
i'll try to explain what i'm trying (without satisfing results) to achive though it might not be easy.
Generally i want to put few widgets in a layout (say QVBoxLayout) that will be displayed with different sizes and alignment on S60 phones with different vertical pixels count (640px and 320px)
Lets say that ideal vertical size of all my widgets (sum of their ideal height) is 360px. So as you can see it is smaller thetn 640 and greater then 320.
When displayed on smaller display i want widgets to scale verticaly to fit whole screen (320px) but when on the bigger display i want them to have their maximum (360px) size AND aligned on top (so the unused space is at the bottom of the screen).
This is more or less the code i use (it was used to make third screenshot)
Example::Example(QWidget *parent) :
QWidget(parent)
{
setStyleSheet("QLabel {border: 2px solid green;}"); // just to make labels size visible
QVBoxLayout *mainLayout = new QVBoxLayout(this);
QLabel* label1 = new QLabel("Label 1");
QLabel* label2 = new QLabel("Label 2");
QLabel* label3 = new QLabel("Label 3");
label1->setMaximumHeight(120);
label2->setMaximumHeight(120);
label3->setMaximumHeight(120);
mainLayout->addWidget(label1);
mainLayout->addWidget(label2);
mainLayout->addWidget(label3);
label1->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Maximum);
label2->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Maximum);
label3->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Maximum);
setLayout(mainLayout);
}
And screenshots:
1) This is how it should look on smaller display (widgets are smaller then max size, they fill the whole screen)
4807
2) This is how it should look on bigger display (widgets have their maximum size, empty space at the bottom)
NOTE: this was achieved by setting stretch for every label and inserting stretch at the end - so it only looks like something i want to achieve, in fact it isn't
4806
3) This is what i managed to achieve (widgets have the right size but they are not top aligned)
4805
As far as i can remember it is my first post here so please be patient if i did not include some important info :)
i'll try to explain what i'm trying (without satisfing results) to achive though it might not be easy.
Generally i want to put few widgets in a layout (say QVBoxLayout) that will be displayed with different sizes and alignment on S60 phones with different vertical pixels count (640px and 320px)
Lets say that ideal vertical size of all my widgets (sum of their ideal height) is 360px. So as you can see it is smaller thetn 640 and greater then 320.
When displayed on smaller display i want widgets to scale verticaly to fit whole screen (320px) but when on the bigger display i want them to have their maximum (360px) size AND aligned on top (so the unused space is at the bottom of the screen).
This is more or less the code i use (it was used to make third screenshot)
Example::Example(QWidget *parent) :
QWidget(parent)
{
setStyleSheet("QLabel {border: 2px solid green;}"); // just to make labels size visible
QVBoxLayout *mainLayout = new QVBoxLayout(this);
QLabel* label1 = new QLabel("Label 1");
QLabel* label2 = new QLabel("Label 2");
QLabel* label3 = new QLabel("Label 3");
label1->setMaximumHeight(120);
label2->setMaximumHeight(120);
label3->setMaximumHeight(120);
mainLayout->addWidget(label1);
mainLayout->addWidget(label2);
mainLayout->addWidget(label3);
label1->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Maximum);
label2->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Maximum);
label3->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Maximum);
setLayout(mainLayout);
}
And screenshots:
1) This is how it should look on smaller display (widgets are smaller then max size, they fill the whole screen)
4807
2) This is how it should look on bigger display (widgets have their maximum size, empty space at the bottom)
NOTE: this was achieved by setting stretch for every label and inserting stretch at the end - so it only looks like something i want to achieve, in fact it isn't
4806
3) This is what i managed to achieve (widgets have the right size but they are not top aligned)
4805
As far as i can remember it is my first post here so please be patient if i did not include some important info :)