Scrollbar always grayed out
Hello,
i used QtDesigner for placing a QScrollArea into a QWidget and placing a QGridLayout into this QScrollArea. Now i add QLabels into the GridLayout
Code:
lab
->setPixmap
(QPixmap::fromImage(img
));
lab->setMinimumSize(img.size());
m_ui.gridLayout->addWidget(lab, m_currentRow, m_currentColumn);
}
The Labels are added and displayed correctly, but if i add more labels than my Widget can display, the scrollbars (ScrollbarAlwaysOn) are still grayed out.
What has to be done?
Thanks in advance
Garg
Re: Scrollbar always grayed out
set the "widgetResizable" property of the scroll area to true.
Re: Scrollbar always grayed out
it is true...
here is the code generated from QtDesigner
Code:
void setupUi
(QWidget *ImageViewerClass
) {
//...
sizePolicy.setHorizontalStretch(0);
sizePolicy.setVerticalStretch(0);
sizePolicy.setHeightForWidth(scrollArea->sizePolicy().hasHeightForWidth());
scrollArea->setSizePolicy(sizePolicy);
scrollArea->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOn);
scrollArea->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOn);
scrollArea->setWidgetResizable(true);
scrollAreaWidgetContents
= new QWidget();
gridLayoutWidget
= new QWidget(scrollAreaWidgetContents
);
gridLayout
->setObjectName
(QString::fromUtf8("gridLayout"));
gridLayout
->setSizeConstraint
(QLayout::SetMinAndMaxSize);
gridLayout->setContentsMargins(0, 0, 0, 0);
scrollArea->setWidget(scrollAreaWidgetContents);
I dont know where i can find more information (looked into api, qt-book, goole)
1 Attachment(s)
Re: Scrollbar always grayed out
And how do you add the labels to the widget? Could you post the ui file? Mine is attached and works fine.
Re: Scrollbar always grayed out
they are added at runtime
Code:
void ImageViewer
::addImage(const QImage &img
) {
lab
->setPixmap
(QPixmap::fromImage(img
));
lab->setMinimumSize(img.size());
m_ui.gridLayout->addWidget(lab, m_currentRow, m_currentColumn);
}
mine makes it the indirect way about "GridLayoutWidget"
Re: Scrollbar always grayed out
Now i coded it manually without using VS Integration and it works ;-) seems to generate stupid code?
ty