How are you determining that the label does not get resized?
#include <QtGui>
#include <QDebug>
int main(int argc, char *argv[])
{
layout->addWidget(label);
widget.setLayout(layout);
qDebug() << widget.size() << label->size();
widget.show();
qDebug() << widget.size() << label->size();
widget.resize(320, 200);
qDebug() << widget.size() << label->size();
return app.exec();
}
#include <QtGui>
#include <QDebug>
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
QWidget widget;
QVBoxLayout *layout = new QVBoxLayout;
QLabel *label = new QLabel("test");
layout->addWidget(label);
widget.setLayout(layout);
qDebug() << widget.size() << label->size();
widget.show();
qDebug() << widget.size() << label->size();
widget.resize(320, 200);
qDebug() << widget.size() << label->size();
return app.exec();
}
To copy to clipboard, switch view to plain text mode
out:
QSize(640, 480) QSize(640, 480)
QSize(47, 39) QSize(25, 17)
QSize(320, 200) QSize(298, 178)
To copy to clipboard, switch view to plain text mode
Some layout resizing is not done until the widget is displayed, but the label is resized.
Bookmarks