C++ GUI Qt4編程(01)-1.1Hello Qt

來源:互聯網
上載者:User

標籤:整理   show   div   return   問題   別名   添加   centos   根據   

1. 根據C++ GUI Qt4編程(第二版)整理
2. 系統:centos7;  Qt版本:5.5.1
3. 程式:hello.cpp

#include <QApplication>#include <QLabel>int main(int argc, char *argv[]){    QApplication app(argc, argv);    QLabel *label = new QLabel("Hello, Qt!");    label->show();    return app.exec();}

4. qmake使用別名:$ alias qmake="/opt/Qt/Qt5.5.1/5.5/gcc_64/bin/qmake"
5. 產生與平台無關的專案檔:$ qmake -project
6. 產生與平台相關的makefile檔案:$ qmake 1.1.pro        
7. 構建該程式,產生可執行程式:$ make
8. 運行程式:$ ./1.1
註:1.1是檔案夾名稱


問題總結:
1. hello.cpp:1:24: 致命錯誤:QApplication:沒有那個檔案或目錄
    解決方案:開啟1.1.pro檔案,添加以下2行:
  QT += core gui
  greaterThan(QT_MAJOR_VERSION, 4): QT += widgets

 

C++ GUI Qt4編程(01)-1.1Hello Qt

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.