代码改变世界

Qt ----hello World

2016-07-10 10:37  慢跑的小菜  阅读(141)  评论(0编辑  收藏  举报

查看 ubuntu 和  Qt的版本

Qt的版本也可以在 Qtcreator上面查看

 

Qt的版本 可以到   https://www.qt.io/download/ 注册后下载

使用root权限安装后即可以使用。

 

#include <QCoreApplication>
#include<QApplication>

#include<QPushButton>

//#include <qapplication.h>
//#include <qmainwindow.h>
int main(int argc, char *argv[])
{
     QApplication app(argc, argv );

      QPushButton*hello = new QPushButton( "Hello world!", 0 );

      hello-> resize( 100, 30 );

     hello-> show();
    return app.exec();
}

注:程序是引自CSDN网友

 

错误:QMainWindow: No such file or directory 解决方法

并且在.pro文件中加上

QT       += core gui
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets

Picture of my project