Qt QMessageBox 之模態非模態

2021-07-24 14:24:01 字數 781 閱讀 7029

qt 的訊息框用起來比新建對話方塊方便一些。有兩種呼叫方法,靜態的和動態的。

一、靜態呼叫

例子:

qmessagebox::warning(	qwidget *parent,

const qstring& title,

const qstring& text,

standardbuttons buttons=ok,

standardbutton defaultbutton = nobutton

);

注意warning 是小寫。

只要新增了 標頭檔案就可以方便的呼叫訊息框。但是,注意靜態方法呼叫的訊息框總是模態的。

二、動態呼叫

例子:

qmessagebox *box = new qmessagebox(icon icon,

const qstring& title,

const qstrign& text,

standardbuttons buttons=ok,

standardbutton defaultbuttons = nobutton);

icon 是指訊息框型別,如:qmessagebox::warning;

注意此時的warning是首字母大寫的。

此時可以呼叫 qmessagebox::setmodal(bool)函式來設定模態或者非模態。

true為模態,false為非模態。

大家軟體寫完了可以考慮發表成果,軟體著作權,**低至300元。

qt QMessageBox中按鈕的漢化

方法一 直接新增漢語按鈕 qmessagebox mess qmessagebox question,刪除提示 確認刪除所選元件?null qpushbutton okbutton mess.addbutton tr 確定 qmessagebox acceptrole qpushbutton can...

python之 socketserver模組的使用

在我們正常的使用socket模組來寫乙個server的程式就會顯得比較的複雜通常一般流程為 1.生成socket例項物件 2.繫結位址 3.開始監聽 4.接收資料 一般demo為 伺服器import socket server socket.socket 宣告socket型別,同時生成socket連...

python模組之subprocess模組

import subprocess sh 3.2 ls users egon desktop grep txt mysql.txt tt.txt 事物.txt res1 subprocess.popen ls users jieli desktop shell true,stdout subproc...