1、對(duì)話框分類
①M(fèi)odal 模式對(duì)話框:彈出后技俐,背景界面卡主统台。
②Non-Modal 非模式對(duì)話框:背景界面可正常編輯。
2捂刺、模式對(duì)話框(QDialog)
主要有三個(gè)函數(shù):
accept()
reject()
exec()
點(diǎn)擊確定按鈕后執(zhí)行accept()
會(huì)使得exec()
返回Dialog::Accepted,點(diǎn)擊取消按鈕后執(zhí)行reject()悬垃,exec()返回Dialog::Reject。
3列肢、文件對(duì)話框(QFileDialog)
常用方法
QString filePath = QFileDialog::getOpenFileName(
this,// 父窗口
GBK::ToUnicode("選擇文件")// 窗口title
)
QString filePath = QFileDialog::getSaveFileName(
this,// 父窗口
GBK::ToUnicode("選擇文件")// 窗口title
)
4宾茂、非模態(tài)窗口
使用方法
①創(chuàng)建一個(gè)Widget派生類,作為非模態(tài)窗口欧聘。
m_searchWindow = new MySearchWindow(this);
m_searchWindow->setWindowFlags(Qt::Window);
connect(ui.startSearchBtn, SIGNAL(clicked()), this, SLOT(SearchBtnClicked()));
②在父窗口中創(chuàng)建對(duì)象非模態(tài)窗口對(duì)象端盆,在相應(yīng)方法中執(zhí)行顯示動(dòng)作。
void MyWin3::SearchBtnClicked() {
m_searchWindow->show();
}