我的设置如下所示:
Main Window
|- QHBoxLayout
|- Some Widgets
|- QScrollArea
| |- QHBoxLayout
| |- QGridLayout
| |- Widgets dynamically loaded in at runtime
| |- QVBoxLayout
|- Some Widgets
Run Code Online (Sandbox Code Playgroud)
添加小部件后,我希望滚动区域完全向下滚动。我这样做了:
this->ui->gridLayout_table->addWidget(/*Widget*/); // this works perfectly nice
this->ui->gridLayout_table->addWidget(/*Widget*/); // this also works perfectly nice
this->ui->scrollArea->verticalScrollBar()->setValue(this->ui->scrollArea->verticalScrollBar()->maximum());
Run Code Online (Sandbox Code Playgroud)
在最后一个命令中,它滚动到最大值减去新添加的小部件的高度。有没有办法在滚动之前刷新更改?
提前致谢 卢卡斯