zoukankan      html  css  js  c++  java
  • QT的第一个程序_hello world!

      今天实现了一个QT入门程序神奇hello world!把这几天的学习心得记录下来。新手学习任何新知识总是会经历大量曲折,一定是发大量时间收集资料然后是看视频,其实都不如自己动手操作,这样才会有成就感,毕竟看老司机玩的很溜还不如自己上路。废话不多说,上资料和程序!

      一资料参考《Qt Creator快速入门》和《Qt及Qt Quick开发实战精解》这两本对初学者很有用,还有相关的网站:QTCN开发网 http://www.qtcn.org/bbs/i.php 和 QT开源社区 http://www.qter.org/portal.php?mod=view&aid=52  QT下载网站:https://download.qt.io/official_releases/qt/5.8/5.8.0/

      二一个hello world程序 

      文件名 hello.cpp

     1 #include <QApplication>
     2 #include <QDialog>
     3 #include <QLabel>
     4 
     5 int main(int argc,  char *argv[])
     6 {
     7       QApplication app(argc, argv);
     8       QDialog w;
     9       w.resize(400, 300);
    10 
    11       QLabel label(&w);
    12       label.move(120, 120);
    13       label.setText("Hello World!  加油!!");
    14 
    15       w.show();
    16       return app.exec();          
    17 }

        效果图:

          

    新手注意事项:

      在创建项目时首先生成的 xxx.pro文件

    1 QT += core gui
    2 
    3 greatherThan(QT_MAJOR_VERSION,  4) : QT += widgets
    4 
    5 SOURCES += 
    6     hello.cpp

      

     

  • 相关阅读:
    POJ 1703 Find them, Catch them
    POJ 2236 Wireless Network
    POJ 2010 Moo University
    POJ 2184 Cow Exhibition
    POJ 3280 Cheapest Palindrome
    POJ 3009 Curling 2.0
    POJ 3669 Meteor Shower
    POJ 2718 Smallest Difference
    POJ 3187 Backward Digit Sums
    POJ 3050 Hopscotch
  • 原文地址:https://www.cnblogs.com/aixzhi/p/7143220.html
Copyright © 2011-2022 走看看