QT笔记

 

 

#include "qt41.h"
#include <QtGui/QApplication>
#include "qlabel.h"
#include "qtextcodec.h"
#include <qpushbutton.h>
#include "QtGui\qboxlayout.h"

int main(int argc, char *argv[])
{
    QApplication a(argc, argv);
    QTextCodec::setCodecForTr(QTextCodec::codecForName("gb18030"));
    QWidget* pWidget = new QWidget;
    QLabel label(pWidget);
    label.setText(QObject::tr("同一个世界,同一个梦想"));
    
    QVBoxLayout* layout = new QVBoxLayout();
    layout->addWidget(&label);
    QPushButton* btn = new QPushButton(QObject::tr("关闭"), pWidget);
    layout->addWidget(btn);
    pWidget->setLayout(layout);

    QObject::connect(btn, SIGNAL(clicked()), pWidget, SLOT(close()));

    
    pWidget->show();
    //qt41 w;
    //w.show();
    return a.exec();
}

 

posted @ 2018-09-29 17:18  yasepix  阅读(94)  评论(0编辑  收藏  举报