目錄
qmake的作用
簡單的小例子
跨平台的例子
1.生成makefile檔案;
2.生成moc和uic檔案;
3.用vs開啟qt時無需要改變pro檔案就能能夠生成專案;
在linux中qmake的主要目的是簡化程式設計師編寫makefile;
手寫乙個簡單的pro檔案,用再用qmake下;
首先寫乙個小例子:
包含4個檔案:
hello.h、hello.cpp、main.cpp、hello.pro
原始碼如下:
hello.h
#include using namespace std;
class hello;
hello.cpp
#include "hello.h"
hello::hello()
void hello::print()
main.cpp
#include "hello.h"
int main()
hello.pro
target = helloworld
config += debug
headers += hello.h
sources += hello.cpp \
main.cpp
target一般與pro檔案同名,但字尾名應平台而異,如exe是windows平台上的,無字尾是unix上的,如果想設定乙個其他的名字,可以在此設定其他名稱;
使用這條命令生成makefile
qmake -o makefile hello.pro
linux的操作如下圖所示:
隨後使用make即可
在vs中想上次vc的檔案要使用下面這條命令:
qmake -tp vc hello.pro -spec win32-msvc2012
windows的操作如下圖:
設定好,vs,如果沒輸出,注意設定控制台輸入,如下圖所示:
執行截圖如下:
存在下面幾個檔案:
hello.cpp、hello.h、hellounix.cpp、hellounix.h、hellowin.cpp、hellowin.h、main.cpp、hello.pro
具體內容如下:
hello.h
#include using namespace std;
class hello;
hello.cpp
#include "hello.h"
hello::hello()
void hello::print()
hellounix.h
#include using namespace std;
class unixhello;
hellounix.cpp
#include "hellounix.h"
unixhello::unixhello()
void unixhello::print()
hellowin.h
#include using namespace std;
class winhello;
hellowin.cpp
#include "hellowin.h"
winhello::winhello()
void winhello::print()
main.cpp
#include "hello.h"
#include "hellowin.h"
#else
#include "hellounix.h"
#endif
int main()
hello.pro
target = helloworld
config += debug
headers += hello.h
sources += hello.cpp \
main.cpp
win32
unix
在linux上執行截圖如下:
在windows上執行截圖如下:
如果想除錯程式可以使用config這個變數,標記程式為debug版本
如下所示:
原始碼如下:
config += debug
headers += hello.h
sources += hello.cpp
sources += main.cpp
如果想除錯程式可以使用config這個變數,標記程式為debug版本
如下所示:
win32
使用win32與unix來決定跨平台的特性【前提是各個平台的**分離】
如下所示:
config += debug
headers += hello.h
sources += hello.cpp
sources += main.cpp
win32
unix
exists命令,當缺少檔案的時候會停止qmake
win32
}
後面這個是在windows上,想調出控制台的時候(qdebug能列印),需要做的事 Kafka文件閱讀筆記 1 入門
kafka是乙個分布式訊息系統,用於構建實時資料通道和流應用程式。kafka具有橫向擴充套件和容錯等優點,具有很高的吞吐量,可以處理更大規模的訊息。可以應用在 行為追蹤 使用者行為追蹤 日誌聚合等場景。kafka具有4個核心api,生產者api 消費者api 流處理api 聯結器api,生產者api...
Qt文件閱讀筆記 構造WebSocket服務端
目錄 基本概念 與例項 因為週末搞了個spring boot的,但是想想,這個websocket只是乙個協議而已,c 應該也能搞,在此就搞了這篇博文,這裡主要是用qt,寫websocket,然後用html寫前端,讓連線上的客戶端,進行傳送資料,接收資料,單獨傳送等等等,也就是使用websocket做...
Qt文件閱讀筆記 Qt Core的官方解析
qt core 目錄 getting started threading and concurrent programming input output,resources,containers additional frameworks 所有的qt模組都依賴qtcore。想包含這個模組下各種類的定...