主要有 三个 widget.h widget.cpp main.cpp
#ifndef WIDGET_H #define WIDGET_H #include <QWidget>
class Widget : public QWidget{ Q_OBJECT public: Widget(QWidget *parent = 0); ~Widget(); };
#endif // WIDGET_H
this->resize(900,400);// 推荐使用 qDebug()<<this->size()<<endl;//没有上边的resize() 是(640,480) resize()之后就变了 // qDebug()<<this->sizeHint()<<endl;//在布局管理其中 推荐使用 } Widget::~Widget(){}
#include "widget.h" #include <QApplication> int main(int argc, char *argv[]){ QApplication a(argc, argv); Widget w; w.show(); return a.exec(); }