Scroll area is smaller than dialog
-
Hi,
I have the following scroll area:QScrollArea *scroll = new QScrollArea(this); scroll->setVerticalScrollBarPolicy (Qt::ScrollBarAlwaysOn); scroll->setHorizontalScrollBarPolicy (Qt::ScrollBarAlwaysOn); QWidget *viewport = new QWidget(this); scroll->setWidget (viewport); scroll->setWidgetResizable (true); QFormLayout *layout = new QFormLayout(viewport); viewport->setLayout (layout); layout->setSpacing (60); // Title Row setup QHBoxLayout *titleRow = new QHBoxLayout(viewport); titleRow->addWidget (Title); //Creating the Name row QHBoxLayout *NameRow = new QHBoxLayout(viewport); NameRow->addWidget (Label_Name); NameRow->addWidget (LineEdit_Name); NameRow->addSpacing (10); NameRow->addWidget (angry_image_Label); NameRow->addSpacing (10); NameRow->addWidget (incorrect_Label); NameRow->addSpacing (350); // Interspace layout->setVerticalSpacing (30); QLabel *spacer_Label = new QLabel; // Displaying the rows layout->addRow(titleRow); layout->addRow (spacer_Label,spacer_Label); layout->addRow (Label_ID,ID_Display); layout->addRow (NameRow); }
It produces the following dialog:
Image
Please help me to find out why the scrolling area is smaller than the dialog.
Thank you. -
Hi @gabor53
Set Grid-layout in the Dialog. Make Gridlayout inside the Dialog for the Scrollarea.Roughly the design of widgets looks like this.
Dialog ( gridlyout ( Scrollarea( layout( yourwidget's)))) .
Add this..
QGridLayout *sam = new QGridLayout;
sam->addWidget(your scrollarea );
Dialogname->setlayout(sam) -