Use this:
QScrollView * sv = new QScrollView( this );
w->setPaletteBackgroundColor(Qt::white);
sv->addChild(w);
sv->setResizePolicy(QScrollView::AutoOneFit);
QScrollView * sv = new QScrollView( this );
QWidget * w = new QWidget(sv->viewport());
w->setPaletteBackgroundColor(Qt::white);
sv->addChild(w);
sv->setResizePolicy(QScrollView::AutoOneFit);
To copy to clipboard, switch view to plain text mode
The magic line is the resize policy, which causes your widget to be resized to the viewport size. The result is fine, but not perfect. Something is messed up with the widget height, but I didn't want to get into the code too deep. I'm sure you'll manage to fix it. It's probably caused by heightForWidth in the layout.
Bookmarks