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

  

posted @ 2016-11-28 16:23  mCat  Views(233)  Comments(0)    收藏  举报