1
目前我有這樣的代碼到幾QLineEdits添加到ui.widget
,但我還需要一個垂直滾動條元素過多的情況下 - >可用的空間有限:使用滾動條與QGridLayout
QGridLayout *gridLayout = new QGridLayout(ui.widget);
int rowIndex = 0, colIndex = 0;
for(auto number : m_numbers)
{
QLineEdit *lineEdit = new QLineEdit();
gridLayout->addWidget(lineEdit, rowIndex, colIndex, Qt::AlignLeft);
if(colIndex == 7)
{
colIndex = 0;
++rowIndex;
}
else ++colIndex;
}
ui.widget->setLayout(gridLayout);
我怎樣才能使滾動?
您是否有基於我的代碼的完整示例? Thx – leon22
我認爲QScrollArea對你有好處,爲什麼不呢?而QScrollBar也可以完成這項工作。 – aghilpro
我試圖改變它,但不起作用!在ui.widget-> setLayout(gridLayout);之後我添加了QScrollArea * scrollArea = new QScrollArea; scrollArea-> setWidget(ui.widget); - >它沒有元素是空的。 – leon22