You probably have to set the size constraint for the layout of the main window. You can't do it from within Designer, you have to code it manually in your project.
#include <QtGui>
public:
for(int i=0;i<3;++i)
x = 0;
startTimer(2000);
}
protected:
if(++x==7) killTimer(e->timerId());
}
private:
int x;
};
int main(int argc, char **argv){
mw.
layout()->setSizeConstraint
(QLayout::SetFixedSize);
Widget *w = new Widget;
mw.setCentralWidget(w);
mw.show();
return app.exec();
}
#include <QtGui>
class Widget : public QWidget {
public:
Widget() : QWidget() {
l = new QVBoxLayout(this);
for(int i=0;i<3;++i)
l->addWidget(new QPushButton);
x = 0;
startTimer(2000);
}
protected:
void timerEvent(QTimerEvent *e){
l->addWidget(new QPushButton);
if(++x==7) killTimer(e->timerId());
}
private:
QVBoxLayout *l;
int x;
};
int main(int argc, char **argv){
QApplication app(argc, argv);
QMainWindow mw;
mw.layout()->setSizeConstraint(QLayout::SetFixedSize);
Widget *w = new Widget;
mw.setCentralWidget(w);
mw.show();
return app.exec();
}
To copy to clipboard, switch view to plain text mode
Bookmarks