Examples of setting up a QScrollArea
-
Ugh. Scrollbars.
I have a need where I have a splitter with two panels. On the left panel, I need to insert a QScrollArea. Inside the QScrollArea, I have custom QWidget that draws a custom hierarchy tree.
So far, I have things sorta working with this setup code:
@ m_hierWindow = new HierWidget(this);
m_hierWindow->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);// SETUP MAIN WINDOW
m_scroller = new QScrollArea(this);
m_scroller->setBackgroundRole(QPalette::Dark);
ui->TreeView->addWidget(m_scroller);
ui->ModelView->addWidget(m_model);m_scroller->setWidget(m_hierWindow);
@Can someone point me to a good tutorial of how to setup the QScrollArea inside a splitterwindow? I see this done all the time in Qt Creator. It can't be that difficult.
Thanks in Advance
-
Hi,
The code you posted is a bit confusing.
@
ui->TreeView->addWidget(m_scroller); <- TreeView is a layout ?
ui->ModelView->addWidget(m_model); <- ModelView is a layout ? m_model a widget ?
@In short for using a QScrollArea in a QSplitter:
@
QSplitter *splitter = new QSlitter;
QScrollArea *scrollArea = new QScrollArea;
splitter->addWidget(scrollArea);// Modify scrollArea as you see fit
@Hope it helps