Hi,
I've used the following code snippet to add scroll area inside dock widget
m_pMapInfoWidget->setObjectName(QStringLiteral("Map Info Widget"));
m_pMapInfoWidget
->setFeatures
(QDockWidget::NoDockWidgetFeatures);
m_pMapInfoWidget->setAllowedAreas(Qt::RightDockWidgetArea);
m_pMapInfoWidget->setMinimumSize(285, 500);
addDockWidget(Qt::RightDockWidgetArea, m_pMapInfoWidget);
// Create scroll area for the widget
m_pMapInfoScrollArea->setObjectName(QStringLiteral("MapInfoScrollArea"));
m_pMapInfoScrollArea->setWidgetResizable(true);
m_pMapInfoScrollArea->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOn);
m_pMapInfoScrollArea
->setFrameStyle
(QFrame::NoFrame);
m_pMapInfoScrollArea->show();
// Scroll area content
m_pInfoContent->setObjectName(QStringLiteral("InfoContent"));
m_pGPSGroupBox->setObjectName(QStringLiteral("GPSGroupBox"));
m_pGPSGroupBox->setFont(infoFont);
m_pGPSGroupBox->setTitle("Heading");
m_pGPSGroupBox
->setGeometry
(QRect(3,
20,
270,
170));
m_pLatLabel->setObjectName(QStringLiteral("LatLabel"));
m_pLatLabel
->setGeometry
(QRect(20,
30,
51,
16));
m_pLatLabel->setFont(infoFont);
m_pLatLabel->setText("Latitude");
m_pMapInfoScrollArea->setWidget(m_pInfoContent);
m_pMapInfoWidget->setWidget(m_pMapInfoScrollArea);
QDockWidget *m_pMapInfoWidget = new QDockWidget(this);
m_pMapInfoWidget->setObjectName(QStringLiteral("Map Info Widget"));
m_pMapInfoWidget->setFeatures(QDockWidget::NoDockWidgetFeatures);
m_pMapInfoWidget->setAllowedAreas(Qt::RightDockWidgetArea);
m_pMapInfoWidget->setMinimumSize(285, 500);
addDockWidget(Qt::RightDockWidgetArea, m_pMapInfoWidget);
// Create scroll area for the widget
QScrollArea *m_pMapInfoScrollArea = new QScrollArea();
m_pMapInfoScrollArea->setObjectName(QStringLiteral("MapInfoScrollArea"));
m_pMapInfoScrollArea->setWidgetResizable(true);
m_pMapInfoScrollArea->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOn);
m_pMapInfoScrollArea->setFrameStyle(QFrame::NoFrame);
m_pMapInfoScrollArea->show();
// Scroll area content
QWidget *m_pInfoContent = new QWidget();
m_pInfoContent->setObjectName(QStringLiteral("InfoContent"));
QGroupBox *m_pGPSGroupBox = new QGroupBox(m_pInfoContent);
m_pGPSGroupBox->setObjectName(QStringLiteral("GPSGroupBox"));
m_pGPSGroupBox->setFont(infoFont);
m_pGPSGroupBox->setTitle("Heading");
m_pGPSGroupBox->setGeometry(QRect(3, 20, 270, 170));
QLabel *m_pLatLabel = new QLabel(m_pGPSGroupBox);
m_pLatLabel->setObjectName(QStringLiteral("LatLabel"));
m_pLatLabel->setGeometry(QRect(20, 30, 51, 16));
m_pLatLabel->setFont(infoFont);
m_pLatLabel->setText("Latitude");
m_pMapInfoScrollArea->setWidget(m_pInfoContent);
m_pMapInfoWidget->setWidget(m_pMapInfoScrollArea);
To copy to clipboard, switch view to plain text mode
When executing the above code we are getting a scroll area, but there is no scroll bar in it.
When i resize the window, we are not getting the scroll bar.
Kindly help us to resolve this.
Bookmarks