scrollbar in QGroupBox
-
@Apeksha
simply use a QScrollArea -
@Apeksha
isn't that the default behavior of QScrollArea anyways?! -
@Apeksha said in scrollbar in QGroupBox:
Actually my requirement is, I have to add scrollbar to groupbox and it should visible when it is minimized.
yes i got that. And again, this is what QScrollArea already does by default.
So maybe you can post a screenshot of your issue.Maybe you want to use
scrollArea->setWidgetResizeable( true )
but still set a minimum size of the content-widget inside the scroll area. When the scroll area gets smaller than the minimum size the scrollbars will be shown. If it is bigger then the specified minimum-size the widget will be resized and use the extra space.Is that what you want?
-
Hi raven-worx,
QHBoxLayout *ConfigurationLayout = new QHBoxLayout; QScrollArea* scrollArea = new QScrollArea(); scrollArea->setStyleSheet("QScrollArea {background-color:gray;}"); ConfigurationLayout->addWidget(ui->configurationBox);////ui->configurationbox is QGroupBox. mainBoxLayout->addLayout(ConfigurationLayout);
This is correctway or anything wrong I am doing.
-
@Apeksha
you dont add any widget to the scroll-area, i dont see any group-box widget and i don't see anysetWidgetResizable()
call.
Hard to say if you are doing all right, when you just post half of the code. -
QHBoxLayout *ConfigurationLayout = new QHBoxLayout;
QScrollArea *scrollArea = new QScrollArea;
scrollArea->setStyleSheet("QScrollArea {background-color:gray;}");
// ui->scrollArea->widgetResizable(true);
// scrollArea->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOn);
// scrollArea->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOn);
scrollArea->setWidget(ui->configurationBox);
ConfigurationLayout->addWidget(ui->configurationBox);
scrollArea->setWidgetResizable(true);
// ConfigurationLayout->addWidget(ui->scrollArea);
mainBoxLayout->addLayout(ConfigurationLayout); -
@Apeksha
so still nosetMinimumSize()
call...
Beside that, are there any questions left from your side?! -
QWidget* contentWidget = ... contentWidget->setMinimumSize( 500,500 ); QScrollArea *scrollArea = new QScrollArea; scrollArea->setStyleSheet("QScrollArea {background-color:gray;}"); scrollArea->setWidget( contentWidget ); scrollArea->setWidgetResizable(true); QVBoxLayout* groupBoxLayout = new QVBoxLayout; groupBoxLayout->addWidget( scrollArea ); QGroupBox* groupBox = ... groupBox->setLayout( groupBoxLayout );
-
QHBoxLayout *ConfigurationLayout = new QHBoxLayout;
QScrollArea *scrollArea = new QScrollArea;
scrollArea->setStyleSheet("QScrollArea {background-color:rgb(215,214,213);}");
scrollArea->setHorizontalScrollBarPolicy(Qt::ScrollBarAsNeeded);
scrollArea->setVerticalScrollBarPolicy(Qt::ScrollBarAsNeeded);
scrollArea->setWidget(ui->configurationBox);
//ConfigurationLayout->addWidget(ui->configurationBox);
scrollArea->setWidgetResizable(true);
scrollArea->setMinimumSize(811,50);
ConfigurationLayout->addWidget(scrollArea);
mainBoxLayout->addLayout(ConfigurationLayout); -
@Apeksha
yes...and?
Do you have a question?? Does it work for you or not?!