QVBoxLayout* vLayout = new QVBoxLayout(tasksDetailWidget);
QLabel* taskNumLabel = new QLabel(QStringLiteral("), tasksDetailWidget);
//先初始化widget 并设置好布局
taskListWidget = new QWidget;
taskListLayout = new QVBoxLayout(taskListWidget);
taskListLayout->setSpacing(0);
taskListLayout->setAlignment(Qt::AlignTop);
taskListWidget->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
tasksDetailWidget->resize(1000, 800);
//基于父widget创建
QScrollArea* scrollArea = new QScrollArea(tasksDetailWidget);
scrollArea->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
scrollArea->setWidget(taskListWidget); //绑定widget scrollArea成为了widget的父容器
scrollArea->setWidgetResizable(true);//在widget要显示的内容超出范围时 能够改变widget大小 显示内容
vLayout->addWidget(taskNumLabel);
//添加滚动区域
vLayout->addWidget(scrollArea);
QT widget 添加滚动条
最新推荐文章于 2024-10-10 19:58:20 发布