如何使QT TabWidget带有滚动条,我用scrollArea来作,但是显示在了新的窗体中,没有在原来的TabWidget控件

2024-12-03 18:09:31
推荐回答(1个)
回答1:

QGridLayout *layout = new QGridLayout;
layout->setContentsMargins(0, 24, 0, 0);
tabWidget = new QTabWidget;
tabWidget->addTab(new t1(), tr("t1"));
tabWidget->addTab(new t2(), tr("t2"));

QScrollArea *scrollArea = new QScrollArea;
scrollArea->setWidget(tabWidget);
layout->addWidget(scrollArea);
setLayout(layout);