Trying to add a scrollArea to contain a long sequence of QLineEdits
Hi
I developped a window with lots of entry fields, so many that the whole thing doesnt fit onto my screen. So I thought one way out would be to create a scroll area and let the user scroll though this.
Trouble is, all my trials have come to nothing. I was hoping to have a minimal change
Here is the constructor for my window:
Code:
{
m_scrollArea
->setBackgroundRole
(QPalette::Light);
setCentralWidget(m_scrollArea);
this
->m_frame
= new QFrame(this);
m_scrollArea->setWidget(m_vLayout);
// add entry fields and labels to m_vLayout below.
}
I have of course defined some fields called m_scrollArea, m_frame, etc of the types that you would guess.
When I display my window I just get one big blank area.
Please tell me if you want more detail.
I should add that my window derived from QDialog initially, and then I tried to derive it from QMainWindow in the above code.
Re: Trying to add a scrollArea to contain a long sequence of QLineEdits
I think that you are adding an empty frame to m_scrollArea. Try moving m_scrollArea->setWidget(m_frame) to below where you add widgets to your layout.
Re: Trying to add a scrollArea to contain a long sequence of QLineEdits
As norobro alludes, line 9 fails to compile (no matching call). Did you mean:
Code:
m_scrollArea->setWidget(m_frame);
You can add the widget to the scroll area after you fill the layout, or you can:
Code:
m_vLayout
->setSizeConstraint
(QLayout::SetMinAndMaxSize);
to handle the dynamic changes in the layout after you have installed the frame in the scroll area. See the detailed description of QScrollArea for stuff about dynamic layouts.
Re: Trying to add a scrollArea to contain a long sequence of QLineEdits
I figured that was a typo since he said he was getting "one big blank area"
Thanks for the setSizeConstraint() tip!
Re: Trying to add a scrollArea to contain a long sequence of QLineEdits
Yes, I must have copied the version that wouldnt compile. Sorry.
Thanks guys, problem solved.