Qt MessageBox類簡單使用

2021-08-20 21:29:55 字數 1125 閱讀 2390

qmessagebox類提供了乙個有一條簡短訊息、乙個圖示和一些按鈕的模式對話方塊。

訊息框用於提供情報資訊並且問一些簡單的問題。

qmessagebox提供了乙個不同資訊的範圍,大致按兩個軸進行排列:嚴重程度和複雜程度。

按嚴重程度分:訊息;警告;錯誤。

按複雜程度分為乙個按鈕(確定)的簡單訊息、或者用於提問的兩個或者甚至三個按鈕。

1、資訊視窗

[static] int qmessagebox::information(qwidget *parent, const qstring &title, 

const qstring &text,

int button0, int button1 = 0, int button2 = 0)

例:

tr("the time is over.\n"

"do you complete?"),

qmessagebox::yes | qmessagebox::no);

2、警告視窗

[static] int qmessagebox::warning(qwidget *parent, const qstring &title, 

const qstring &text,

int button0, int button1, int button2 = 0)

例:

tr("the schedule is empty.\n"

"add a schedule to the text."),

qmessagebox::ok);

或者自定義qmessagebox物件,使用成員函式。

例:

qmessagebox msgbox;

msgbox.settext("the time is not over.");

msgbox.setinformativetext("do you want to cancel this schedule?");

msgbox.setstandardbuttons(qmessagebox::yes | qmessagebox::no);

int ret = msgbox.exec();

QT messagebox 亂碼解決

by yhluo 2015年5月20日 qtno comments 使用 qt 經常可能遇到中文亂碼的問題,這裡介紹一下 qt 中文視窗和路徑亂碼的解決方法。我的環境是 qt5.2 vs2012 windows8.1 64bit。qt 中文亂碼原因 關於 qt 中文亂碼的原因以及在 qt4 中解決中...

簡單類模板

include include struct student 結構體student template 類模板 實現對任意型別資料進行訪問 class store template store store template t store getelem int main stores1,s2 sto...

簡單工廠類

工廠類就是乙個專門用來建立其它物件的類,工廠模式通常用來返回類似介面的不同的類,工廠的一種常見用法就是建立多型的提供者。通常工廠模式有乙個關鍵的構造,即一般被命名為factory的靜態方法。這個靜態方法可以接受任意數量的引數,並且必須返回乙個物件。簡單工廠模式 inte ce db class my...