PDA

View Full Version : QScrollArea and scroll



uKCuH
1st July 2010, 07:59
I apologize for my English, since this first message in English.

There's a certain analog of the playlist in a videowidget.


scrollArea = new QScrollArea();
scrollAreaWidgetContents = new QWidget();
scrollArea->setWidget(scrollAreaWidgetContents);


After that I add in layout of scrollAreaWidgetContents (QVBoxLayout) many widgets.
How to do so that QScrollArea it was scrolled to necessary to me widget?

While I do so:


MyWidget *selectedWidget = findWidget(id);
selectedWidget->mark();
_ui->scrollArea->ensureWidgetVisible(selectedWidget , 0, 0);


After that necessary widget became selected (after mark()), but QScrollArea to it it was not scrolled.

high_flyer
1st July 2010, 12:22
In your situation you should get the child widget (the one you want to scroll to) position, and then use:
void QScrollArea::ensureVisible ( int x, int y, int xmargin = 50, int ymargin = 50 )