Details
-
Bug
-
Resolution: Invalid
-
Not Evaluated
-
4.5.2
-
None
Description
if widget is not set to be resizable in the scroll area, and child widgets are being added to it in a layout, then adjustSize will get a wrong size and make it too small.
Following snippet demonstrates the problem:
#include <QtGui>
class CustomWidget: public QWidget{
Q_OBJECT
public:
CustomWidget(QWidget *parent = 0, Qt::WindowFlags f = 0) : QWidget(parent, f)
public slots:
void addButton()
;
#include "main.moc"
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
QWidget *mainWidget = new QWidget();
QVBoxLayout layoutA;
mainWidget->setLayout(&layoutA);
QPushButton *pushButton = new QPushButton("Add a widget");
layoutA.addWidget(pushButton);
QScrollArea *scrollArea = new QScrollArea(mainWidget);
CustomWidget *custom = new CustomWidget(scrollArea);
scrollArea->setWidget(custom);
layoutA.addWidget(scrollArea);
QObject::connect( pushButton, SIGNAL(pressed()),
custom, SLOT(addButton()) );
mainWidget->resize( 300, 400 );
mainWidget->show();
return app.exec();
}