QT5入門之15 qr函式

2021-07-06 05:03:29 字數 465 閱讀 4415

qr是乙個函式,是用於實現國際化的。

setwindowtitle(tr("hello"));
如果你為這個程式提供了中文翻譯包(其中hello被翻譯成中文」你好」),那麼標題將是中文」你好」;

如果你為程式提供且使用日文翻譯包,那麼text1的內容將是日文。

qstring qmetaobject::tr(const

char *s, const

char *c) const

qtextcodec::setcodecfortr(qtextcodec::codecforname("gb2312")); 

qtextcodec::setcodecfortr(qtextcodec::codecforname("utf-8"));

有些東西了解就行了,太過深入需要很多時間。

QT5入門之24 QT 容器

和標準stl一樣,qt也有很多容器。qt 提供了順序儲存容器 qlist,qlinkedlist,qvector,qstack 和 qqueue。對於絕大多數應用程式,qlist 是最好的選擇。雖然它是基於陣列實現的列表,但它提供了快速的向前新增和向後追加的操作。如果你需要鍊錶,可以使用 qlink...

QT5入門之23 QT串列埠程式設計

qt5有專門的串列埠類 qserialport 提供訪問串列埠的功能 qserialportinfo 提供系統中存在的串列埠的資訊 具體使用方法 1.在pro檔案中加入 qt serialport 2.mainwindow.h中新增標頭檔案及成員 include include public qse...

QT5入門之8 定時器

在建構函式中啟動定時器 include mainwindow.h include ui mainwindow.h include include include include include mainwindow mainwindow qwidget parent qmainwindow pare...