qt 程式設計技巧

2021-06-18 00:21:29 字數 1184 閱讀 9586

1、qt4一下 解決亂碼:

qtextcodec::setcodecfortr(qtextcodec::codecforlocale());
2、狀態列顯示資料:

ui->statusbar->showmessage(tr("歡迎使用qcom串列埠除錯助手!"));

3 qt學習參考:

4、error: no matching function for call to 'mainwindow::connect(*&, ...)

強制型別轉換一下:

connect((qobject*)(sender),...); 

5、qt 靜態編譯環境的搭建:

1.將c:\qt\2010.05\qt\mkspecs\win32-g++\qmake.conf檔案中的qmake_lflags  = -enable-stdcall-fixup -wl,-enable-auto-import -wl,-enable-runtime-pseudo-reloc

改為qmake_lflags  = -static -enable-stdcall-fixup -wl,-enable-auto-import -wl,-enable-runtime-pseudo-reloc

2.在開始選單裡找到qt command prompt並執行,輸入命令:   configure -static -debug-and-release -no-exceptions  -l "c:\qt\4.8.4\include" -l "c:\qt\4.8.4\lib"

-l指定一下路徑,防止用到vc的標頭檔案

選擇開源:o;選擇license:y;

3.上一條命令執行成功後再輸入命令:   mingw32-make sub-src

等1 ~3 小時可能就執行完了   完成後就ok了。。。

我的環境是windows qt2010.05

4、轉換qt工程為vs工程:

qmake 

-spec win32

-msvc2008

-tp vc

qmake 

-spec win32

-msvc2013

-tp vc

this will convert your project to a .vcproj.

Qt學習筆記 程式設計技巧總結

以命令列的形式改變視窗的現實風格 style cde motif plastique 根據標籤快捷鍵定位輸入框 qlabel label new qlabel tr new qlineedit edit new qlineedit label setbubby edit 預設按鈕 當使用者按下ent...

Qt程式設計技巧 系統托盤設定

trayicon new qsystemtrayicon this 系統托盤 traymenu new qmenu this 托盤選單 traymenu addaction action1 traymenu addaction quitaction10 connect trayicon,signal...

Qt小技巧集錦

除了 和 還可以使用下面的方式注釋 if 0 需要注釋的 endif 使用c語言全域性巨集輸出除錯資訊所在檔案 行號 define cout qdebug file line 建構函式中 cout 結果如圖 注意 file和line兩邊各是兩個下劃線 當然,也可以直接用qdebug輸出 檔案 行號 ...