PDA

View Full Version : How do I make a QDialog's view scrollable ?



ahmadka
9th July 2010, 11:44
Hey guys .. I had a simple question but one I've been unable to find a quick answer to .. I have a QDialog with many buttons and stuff in it ... A picture of it is shown here:

http://i26.tinypic.com/24gre9w.png

As you can see its very cluttered .. What I wanted to do was to make the controls layout scrollable, so that all the controls can be well sized, and to see the controls below, you simply scroll down, like a typical folders list in the N900 ... That way it won't look so cluttered .. Can I set this setting using QDialog only preferably ?

Lesiok
9th July 2010, 12:03
Locating on QDialog QScrollArea (http://doc.trolltech.com/4.6/qscrollarea.html) and putting all widget on them ?

ahmadka
9th July 2010, 23:35
Alright, well I tried adding a QScrollArea and adding on the widgets on the left side of the screen into that, and then adding that to the same QDialog .. But the situation has gotten worse now ..

Firstly, here's the code I was using (only the ending portion relating to adding widgets to layouts, etc ..):


mainSaveQualityModeRadioButtonsLayout = new QHBoxLayout();

mainSaveQualityModeRadioButtonsLayout->addWidget(mainSaveUseDefaultSaveQualityRadioButton );
mainSaveQualityModeRadioButtonsLayout->addWidget(mainSaveUseCustomSaveQualityRadioButton) ;

mainSaveSliderLayout = new QHBoxLayout();
mainSaveSliderLayout->addWidget(mainSaveQualitySlider);
mainSaveSliderLayout->addWidget(mainSaveSliderValueLabel);

mainSaveButtonsLayout = new QVBoxLayout();

mainSaveButtonsLayout->addWidget(mainSaveFileNameText);
mainSaveButtonsLayout->addWidget(mainSaveLocationButton);
mainSaveButtonsLayout->addWidget(mainSaveFormatButton);
mainSaveButtonsLayout->addWidget(mainSaveQualityModeLabel);
mainSaveButtonsLayout->addLayout(mainSaveQualityModeRadioButtonsLayout);
mainSaveButtonsLayout->addLayout(mainSaveSliderLayout);
mainSaveButtonsLayout->addWidget(mainSaveMakeDefaultSaveSettingCheckBox);

mainSaveScrollArea = new QScrollArea();
mainSaveScrollArea->setLayout(mainSaveButtonsLayout);

mainSaveMainButtonLayout = new QVBoxLayout();
mainSaveMainButtonLayout->addWidget(mainSaveButton);

mainSaveOverallLayout = new QHBoxLayout();
mainSaveOverallLayout->addWidget(mainSaveScrollArea);
mainSaveOverallLayout->addLayout(mainSaveMainButtonLayout);


mainSaveDialog = new QDialog();
mainSaveDialog->setLayout(mainSaveOverallLayout);

mainSaveDialog->show();

And here is the result I achieved, with no scroll bar in view ..

http://i27.tinypic.com/2s6v4sx.png

Any suggestions .. ?

Ginsengelf
13th July 2010, 07:15
Hi, try to use a "container widget" for the scroll area. Just create a simple QWidget, add it to mainSaveScrollArea, and set the mainSaveButtonsLayout for this container, not the scroll area itself.

Ginsengelf

wysota
14th July 2010, 15:05
I don't see a call to QScrollArea::setWidget() anywhere...