QGridLayout--01

时间:2023-11-11 18:17:20

QGridLayout--01

#include "mainwindow.h"
#include <QApplication>
#include<QLabel>
#include<QPushButton>
#include <QHBoxLayout>
#include<QVBoxLayout>
#include<QLineEdit> int main(int argc, char *argv[])
{
QApplication a(argc, argv); QWidget *window = new QWidget;
window->setWindowTitle("My app"); QGridLayout *layout = new QGridLayout;
QLabel *label = new QLabel("<h2>Hello cat!"); QLineEdit *txtName = new QLineEdit; layout->addWidget(label,0,0);
layout->addWidget(txtName,0,1); QPushButton *button1 = new QPushButton("ok");
QPushButton *button2 = new QPushButton("cancle");
layout->addWidget(button1,1,0);
layout->addWidget(button2,1,1); window->setLayout(layout); window->show(); return a.exec();
}

  

相关文章