My program has a main window which creates a widget called wdg
. This widget has a QFormLayout
with 193 rows. I want to be able to scroll down the QFormLayout
. I have tried making a QScrollArea
and integrate it with the layout and widget but it results in the widget not showing or scrollbar not showing. I think it has something do with the fact that the height of the new window seems to be as long as the full layout and goes off screen. I tried setting the geometry of the widget to a limited size but it just changed position not size.
Results in widget not showing:
QWidget *wdg = new QWidget;
QScrollArea *scroll = new QScrollArea;
QFormLayout *formLayout = new QFormLayout(wdg);
int lenght = keys.size();
for(int x=0; x<=lenght-1; x++)
{
QComboBox* combo = new QComboBox;
combo->addItem("Present");
combo->addItem("Present and Voting");
combo->addItem("Absent");
combo->addItem("Absent from Commitee");
combo->setProperty("MyIndex", x);
combo->setCurrentIndex(status[x]);
formLayout->addRow(keys.at(x),combo);
connect(combo, SIGNAL(currentIndexChanged(int)), this, SLOT(roll(int)));
}
scroll->setWidget(wdg);
wdg->setLayout(formLayout);
wdg->show();
Results in widget showing but no scrollbar or layout:
QWidget *wdg = new QWidget;
QScrollArea *scroll = new QScrollArea(wdg);
QFormLayout *formLayout = new QFormLayout();
int lenght = keys.size();
for(int x=0; x<=lenght-1; x++)
{
QComboBox* combo = new QComboBox;
combo->addItem("Present");
combo->addItem("Present and Voting");
combo->addItem("Absent");
combo->addItem("Absent from Commitee");
combo->setProperty("MyIndex", x);
combo->setCurrentIndex(status[x]);
formLayout->addRow(keys.at(x),combo);
connect(combo, SIGNAL(currentIndexChanged(int)), this, SLOT(roll(int)));
}
scroll->setLayout(formLayout);
wdg->show();