[Qt-interest] QScrollArea and size issue
Matthieu Dazy
matthieu.dazy at PDGM.com
Mon Dec 1 13:38:19 CET 2008
Hi all,
I'm probably missing something obvious but I fail to understand why the
scrollarea contents are not displayed correctly with the sample code
below. I'd expect the grid layout to provide an adequate sizehint for
the scrollarea widget but it doesn't seem to be the case.
Any hints ?
void add( QGridLayout* gl, int i ) {
gl->addWidget( new QLabel( "XXX" ), i, 0 );
gl->addWidget( new QSpinBox, i, 1 );
gl->addWidget( new QPushButton( "YYY" ), i, 2 );
}
int main( int argc, char** argv ) {
QApplication a( argc, argv );
QWidget* w = new QWidget;
QVBoxLayout* vl = new QVBoxLayout( w );
QScrollArea* sa = new QScrollArea;
vl->addWidget( sa );
QWidget* sa_contents = new QWidget;
sa->setWidget( sa_contents );
QGridLayout* gl = new QGridLayout( sa_contents );
gl->addWidget( new QLabel( "AAA" ), 0, 0 );
gl->addWidget( new QLabel( "BBB" ), 0, 1 );
gl->addWidget( new QLabel( "CCC" ), 0, 2 );
add( gl, 1 );
add( gl, 2 );
add( gl, 3 );
vl->addStretch( 1 );
QPushButton* p = new QPushButton( "&Quit" );
vl->addWidget( p );
QObject::connect( p, SIGNAL( clicked() ), qApp, SLOT( quit() ) );
w->show();
return a.exec();
}
--
Matthieu Dazy (matthieu.dazy at pdgm.com) -- tel. +33 (0)3 83 67 66 19
Paradigm, Nancy -- http://www.pdgm.com
---------------------------------------------------------------------------------------------------------------
This e-mail, including any attached files, may contain confidential and privileged information for the sole use of the intended recipient. Any review, use, distribution, or disclosure by others is strictly prohibited. If you are not the intended recipient (or authorized to receive information for the intended recipient), please contact the sender by reply e-mail and delete all copies of this message.
More information about the Qt-interest-old
mailing list