Qt4.4.3自带教程-Hello world

//HelloWorld.cpp

#include <QApplication>
#include <QPushButton>

int main( int argc, char *argv[])
{
        QApplication app(argc, argv);

   //创建按钮
        QPushButton hello( "Hello world!");
        hello.show(); //显示按钮
        
         return app.exec();
}
 
截图:
 
注:加个标题:
//HelloWorld.cpp

#include <QApplication>
#include <QPushButton>

int main( int argc, char *argv[])
{
        QApplication app(argc, argv);

   //创建按钮
        QPushButton hello( "Hello world!");
        hello.show(); //显示按钮
        
        hello.setWindowTitle( "Hello World App"); //设置标题
        
         return app.exec();
}
 
 
注:
#include <QApplication>
#include <QLabel>

int main( int argc, char* argv[])
{
  QApplication app(argc,argv);
    
  QLabel* lbl= new QLabel( "Hello World");
  lbl->show();
   return app.exec();
}

你可能感兴趣的:(职场,休闲,QT4)