如何在Qt中更改滑块?

huangapple go评论78阅读模式
英文:

How to change slider in Qt?

问题

如何将对象的QVBoxLayout滑块设置到末尾?
我希望初始位置像图片中一样,但滑块位于顶部。

英文:

How to set the slider of an object QVBoxLayout to the end?
I want the initial position to be like in the picture, but the slider is at the top.

MainWindow::MainWindow(QWidget *parent)
    : QMainWindow(parent)
    , ui(new Ui::MainWindow)
{
    ui->setupUi(this);
    QVBoxLayout* lay = new QVBoxLayout(this);
    for (int i = 0; i < 50; ++i) {
        QPushButton* button = new QPushButton(QString(i + '0'));
        lay->addWidget(button);
    }
    ui->scrollContents->setLayout(lay);
}

如何在Qt中更改滑块?

答案1

得分: 3

auto bar = scrollableArea->verticalScrollBar();
bar->setValue(bar->maximum());
英文:
auto bar = scrollableArea->verticalScrollBar();
bar->setValue(bar->maximum());

huangapple
  • 本文由 发表于 2023年7月17日 19:58:09
  • 转载请务必保留本文链接:https://go.coder-hub.com/76704230.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定