{
if (MainWindow->objectName().isEmpty())
MainWindow
->setObjectName
(QString::fromUtf8("MainWindow"));
MainWindow->resize(407, 205);
centralWidget
= new QWidget(MainWindow
);
centralWidget
->setObjectName
(QString::fromUtf8("centralWidget"));
verticalLayout->setSpacing(6);
verticalLayout->setContentsMargins(11, 11, 11, 11);
verticalLayout
->setObjectName
(QString::fromUtf8("verticalLayout"));
scrollArea
->setObjectName
(QString::fromUtf8("scrollArea"));
sizePolicy.setHorizontalStretch(0);
sizePolicy.setVerticalStretch(0);
sizePolicy.setHeightForWidth(scrollArea->sizePolicy().hasHeightForWidth());
scrollArea->setSizePolicy(sizePolicy);
scrollArea
->setMinimumSize
(QSize(0,
100));
scrollArea
->setMaximumSize
(QSize(16777215,
100));
scrollArea->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
scrollArea->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOn);
scrollAreaWidgetContents
= new QWidget();
scrollAreaWidgetContents
->setObjectName
(QString::fromUtf8("scrollAreaWidgetContents"));
scrollAreaWidgetContents
->setGeometry
(QRect(0,
0,
387,
82));
widget
= new QWidget(scrollAreaWidgetContents
);
widget
->setObjectName
(QString::fromUtf8("widget"));
widget
->setGeometry
(QRect(9,
9,
41,
31));
widget
->setStyleSheet
(QString::fromUtf8("background:red;"));
scrollArea->setWidget(scrollAreaWidgetContents);
...
QWidget *centralWidget;
QVBoxLayout *verticalLayout;
QScrollArea *scrollArea;
QWidget *scrollAreaWidgetContents;
QWidget *widget;
QHBoxLayout *horizontalLayout;
QSpacerItem *horizontalSpacer;
QLabel *label;
QLineEdit *widthVal;
QPushButton *pushButton;
QSpacerItem *horizontalSpacer_2;
QSpacerItem *verticalSpacer;
QMenuBar *menuBar;
QToolBar *mainToolBar;
QStatusBar *statusBar;
void setupUi(QMainWindow *MainWindow)
{
if (MainWindow->objectName().isEmpty())
MainWindow->setObjectName(QString::fromUtf8("MainWindow"));
MainWindow->resize(407, 205);
centralWidget = new QWidget(MainWindow);
centralWidget->setObjectName(QString::fromUtf8("centralWidget"));
verticalLayout = new QVBoxLayout(centralWidget);
verticalLayout->setSpacing(6);
verticalLayout->setContentsMargins(11, 11, 11, 11);
verticalLayout->setObjectName(QString::fromUtf8("verticalLayout"));
scrollArea = new QScrollArea(centralWidget);
scrollArea->setObjectName(QString::fromUtf8("scrollArea"));
QSizePolicy sizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
sizePolicy.setHorizontalStretch(0);
sizePolicy.setVerticalStretch(0);
sizePolicy.setHeightForWidth(scrollArea->sizePolicy().hasHeightForWidth());
scrollArea->setSizePolicy(sizePolicy);
scrollArea->setMinimumSize(QSize(0, 100));
scrollArea->setMaximumSize(QSize(16777215, 100));
scrollArea->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
scrollArea->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOn);
scrollAreaWidgetContents = new QWidget();
scrollAreaWidgetContents->setObjectName(QString::fromUtf8("scrollAreaWidgetContents"));
scrollAreaWidgetContents->setGeometry(QRect(0, 0, 387, 82));
widget = new QWidget(scrollAreaWidgetContents);
widget->setObjectName(QString::fromUtf8("widget"));
widget->setGeometry(QRect(9, 9, 41, 31));
widget->setStyleSheet(QString::fromUtf8("background:red;"));
scrollArea->setWidget(scrollAreaWidgetContents);
...
To copy to clipboard, switch view to plain text mode
Notice the QWidget pointer "scrollAreaWidgetContents". That becomes the scroll area's child. When my red widget ("widget") was created, "scrollAreaWidgetContents" was passed as its parent. Normally, I would think that "scrollAreaWidgetContents" would act as a pass-through container, since the QScrollArea object doesn't provide a way of defining its child widget through its Creator properties.
scrollArea->setWidget(widget);
scrollArea->setWidget(widget);
To copy to clipboard, switch view to plain text mode
Bookmarks