I hope someone can help me with my scrollArea problem:
I defined a scroll area and set a tab widget in it:
setCentralWidget( scrollArea_);
scrollArea_->setWidgetResizable ( true );
scrollArea_->setHorizontalScrollBarPolicy( Qt::ScrollBarAsNeeded );
scrollArea_->setVerticalScrollBarPolicy( Qt::ScrollBarAsNeeded
scrollAreaGridLayout_->addWidget(scrollAreaWidget_, 0, 1, 1, 1);
scrollArea_->setWidget(scrollAreaWidget_);
scrollAreaGridLayout2_
= new QGridLayout(scrollAreaWidget_
);
scrollAreaGridLayout2_->addWidget(tabWidget_, 0, 1, 1, 1);
tabWidget_->setEnabled(true);
scrollArea_ = new QScrollArea;
setCentralWidget( scrollArea_);
scrollArea_->setWidgetResizable ( true );
scrollArea_->setHorizontalScrollBarPolicy( Qt::ScrollBarAsNeeded );
scrollArea_->setVerticalScrollBarPolicy( Qt::ScrollBarAsNeeded
scrollAreaGridLayout_ = new QGridLayout(scrollArea_);
scrollAreaWidget_ = new QWidget();
scrollAreaGridLayout_->addWidget(scrollAreaWidget_, 0, 1, 1, 1);
scrollArea_->setWidget(scrollAreaWidget_);
tabWidget_ = new QTabWidget();
scrollAreaGridLayout2_ = new QGridLayout(scrollAreaWidget_);
scrollAreaGridLayout2_->addWidget(tabWidget_, 0, 1, 1, 1);
tabWidget_->setEnabled(true);
To copy to clipboard, switch view to plain text mode
So far everything is fine. Later in the code I change the tabWidget_ contents (and size) and the scrollArea displays correctly.
Depending on the user actions this scrollArea_ should display different things.
So when I change the display:
tabWidget_->hide();
newProfile_->show(); // Another QTabWidget()
scrollAreaGridLayout2_->addWidget(newProfile_, 0, 1, 1, 1);
tabWidget_->hide();
newProfile_->show(); // Another QTabWidget()
scrollAreaGridLayout2_->addWidget(newProfile_, 0, 1, 1, 1);
To copy to clipboard, switch view to plain text mode
The scrollArea gets updated with the new size and appropriate scroll bars.
Problem: my program changes the newProfile_ QabWidget to display other tabs which are bigger but it seems the scrollArea and the scroll bars are not updated and I can't scroll to see the bigger tabs. I tried to get the new size of the tab and resize the QabWidget and the scrollArea but nothing seems to help.
newProfile_->hide();
newProfile_->resize( newQWidgetWidth(), newQWidgetHeight() );
newProfile_->updateGeometry();
scrollArea_->resize( newQWidgetWidth(), newQWidgetHeight() );
scrollArea_->updateGeometry();
scrollAreaWidget_->resize( newQWidgetWidth(), newQWidgetHeight() );
scrollAreaWidget_->updateGeometry();
missionProfile_->show();
scrollAreaGridLayout2_->addWidget(newProfile_, 0, 1, 1, 1);
newProfile_->hide();
newProfile_->resize( newQWidgetWidth(), newQWidgetHeight() );
newProfile_->updateGeometry();
scrollArea_->resize( newQWidgetWidth(), newQWidgetHeight() );
scrollArea_->updateGeometry();
scrollAreaWidget_->resize( newQWidgetWidth(), newQWidgetHeight() );
scrollAreaWidget_->updateGeometry();
missionProfile_->show();
scrollAreaGridLayout2_->addWidget(newProfile_, 0, 1, 1, 1);
To copy to clipboard, switch view to plain text mode
Can anyone suggest a solution?
Bookmarks