当前位置: 代码迷 >> 综合 >> Qt QHBoxLayout 和QVBoxLayout 布局
  详细解决方案

Qt QHBoxLayout 和QVBoxLayout 布局

热度:11   发布时间:2023-10-14 02:37:05.0

Qt QHBoxLayout 和QVBoxLayout 布局

主要有 三个  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

Qt QHBoxLayout 和QVBoxLayout 布局

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();  }