[Interest] QLabel and QScrollArea

igor.mironchik at gmail.com igor.mironchik at gmail.com
Tue Feb 18 11:46:40 CET 2014


Hi.

Is it possible to make the QLabel shrinkable with QScrollArea. I.e. when QScrollArea reduces its width, QLabel should shring its width to the QScrollArea::viewport().width() but grows in height... I tell about QLabel with text, not with pixmap...

class Widget	:	public QWidget{public:	Widget()	{		QVBoxLayout * l = new QVBoxLayout( this );		QScrollArea * scrollArea =			new QScrollArea( this );		QLabel * label = new QLabel;		label->setWordWrap( true );		label->setSizePolicy( QSizePolicy::Minimum,			QSizePolicy::Expanding );		label->setText( QLatin1String( "The volume of the ringer and alerts "			"can be adjusted using the volume buttons. "			"The volume of the ringer and alerts "			"can be adjusted using the volume buttons. "			"The volume of the ringer and alerts "			"can be adjusted using the volume buttons. "			"The volume of the ringer and alerts "			"can be adjusted using the volume buttons. " ) );		scrollArea->setWidget( label );		scrollArea->setWidgetResizable( true );		l->addWidget( scrollArea );	}};

The code above doesn’t work as I expected...

Any ideas?

Thanks.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20140218/b95a9a55/attachment.html>


More information about the Interest mailing list