1 Attachment(s)
Howto: Setup QScrollArea correct? - e.g. scrolling is not working...
Hi,
I've created a scrollArea in a widget and added another widget "pjob" to it,
But it does not scroll automatically as it's described in the Class Reference.
(The Image Viewer example also was not a really help) In the Designer i set: Vertical: ScrollbarAlwaysOn and Horizontal: ScrollBarAsNeeded
Do i have to tell the scrollArea the size of the widget pjob, or does that happen automatically?
Do i need scrollAreaWidgetContents? (It's not in the Qt 4.5 docu ??)
any ideas?
Thanx Astronomy
Code:
m_ui->setupUi(this);
Jobs *pjob = new Jobs();
m_ui->scrollArea->setWidget(pjob);
m_ui->scrollArea->setWidgetResizable(true);
Re: Howto: Setup QScrollArea correct? - e.g. scrolling is not working...
The scroll area will take advice from the internal widget size hint. This is driven by the layout and content of the internal widget. Have a read of the detailed description section in the QScrollArea docs regarding Size Hints and Layouts and try playing with the layout's size constraint.
Re: Howto: Setup QScrollArea correct? - e.g. scrolling is not working...
OK Thank you,
1st i thougt it might work automatically.. :rolleyes:
but i'll dig in :)
greetz Astronomy
Re: Howto: Setup QScrollArea correct? - e.g. scrolling is not working...
Quote:
Originally Posted by
Astronomy
OK Thank you,
1st i thougt it might work automatically.. :rolleyes:
It does but you didn't set a layout for the contents of the scroll area so it has no way of knowing how it should manage its own space.
1 Attachment(s)
Re: Howto: Setup QScrollArea correct? - e.g. scrolling is not working...
Hello again,
today i had the time to solve this problem with your suggestions :)
At: http://doc.trolltech.com/latest/qscr...html#setWidget
is the hint:
Note that You must add the layout of widget before you call this function; if you add it later, the widget will not be visible - regardless of when you show() the scroll area. In this case, you can also not show() the widget later.
With QLayout i had some problems, but at last:
I had to set the minimum size of my custom widget, before i add it to the scrollArea.
So everytime i change the size of pJob because of adding new functionyllity -eg widgets to it scrollArea will adapt automatically.
i did at my constructor:
Code:
...
m_ui->setupUi(this);
Jobs *pjob = new Jobs();
QSize AdjustSize
= pjob
->size
();
AdjustSize.width(); // for debugging...
// Adjust scrollArea to this size,
pjob->setMinimumSize(AdjustSize); // Advantage: everytime you change the size of pJob,
// because of adding new functionyllity -eg widgets to it..
// scrollArea will adapt automatically (-:
m_ui->scrollArea->setWidgetResizable(true);
m_ui->scrollArea->setWidget(pjob);
Thank you very much,
& have a nice day
Astronomy
Re: Howto: Setup QScrollArea correct? - e.g. scrolling is not working...
Quote:
Originally Posted by
Astronomy
Hello again,
today i had the time to solve this problem with your suggestions :)...
Thanks so much. This is the only explicit example I found on line that explain what's going on with scrollarea created with UI not showing properly issue. Solve my doubt and improve my skill. Thanks again.