标准对话框
各種基本對(duì)話框通過調(diào)用各自不同的靜態(tài)函數(shù)來完成其功能,具體說明見表 標(biāo)準(zhǔn)文件對(duì)話框。
其函數(shù)形式如下:
QString QFileDialog::getOpenFileName
( QWidget* parent=0, //標(biāo)準(zhǔn)文件對(duì)話框的父窗口const QString & caption=QString(), //標(biāo)準(zhǔn)文件對(duì)話框的標(biāo)題名const QString & dir=QString(), //注(1)const QString & filter=QString(), //注(2)QString * selectedFilter=0, //用戶選擇的過濾器通過此參數(shù)返回Options options=0 //選擇顯示文件名的格式,默認(rèn)是同時(shí)顯示目錄與文件名
)
?
?
創(chuàng)建一個(gè)標(biāo)準(zhǔn)文件對(duì)話框的詳細(xì)步驟: 在cpp文件的開始部分添加頭文件:#include<QFileDialog>
在實(shí)現(xiàn)函數(shù)中添加如下代碼QString s = QFileDialog::getOpenFileName(this,"open file dialog","/",?"C++ files(*.cpp)::C files(*.c)::Head files(*.h)");
?
標(biāo)準(zhǔn)顏色對(duì)話框。 其函數(shù)形式如下: getColor()函數(shù)是標(biāo)準(zhǔn)顏色對(duì)話框QColorDialog類的一個(gè)靜態(tài)函數(shù),該函數(shù)返回用戶選擇的顏色值,下面是getColor()函數(shù)形式: QColor getColor (const QColor& initial=Qt::white, //注QWidget* parent=0 //標(biāo)準(zhǔn)顏色對(duì)話框的父窗口 );?
?
創(chuàng)建一個(gè)標(biāo)準(zhǔn)文件對(duì)話框的詳細(xì)步驟: 在cpp文件的開始部分添加頭文件: #include <QColorDialog> 在實(shí)現(xiàn)函數(shù)中添加如下代碼 QColor c = QColorDialog::getColor(Qt::blue);?
?
?
標(biāo)準(zhǔn)字體對(duì)話框。 其函數(shù)形式如下: getFont()函數(shù)是標(biāo)準(zhǔn)字體對(duì)話框QFontDialog類的一個(gè)靜態(tài)函數(shù),該函數(shù)返回用戶所選擇的字體,下面是getFont()函數(shù)形式: QFont getFont (bool* ok, //注QWidget* parent=0 //標(biāo)準(zhǔn)字體對(duì)話框的父窗口 );?
?
?
創(chuàng)建一個(gè)標(biāo)準(zhǔn)文件對(duì)話框的詳細(xì)步驟: 在cpp文件的開始部分添加頭文件: #include < QFontDialog> 在實(shí)現(xiàn)函數(shù)中添加如下代碼bool ok;QFont f = QFontDialog::getFont(&ok);if (ok){;}?
?
?
QMessageBox類。 question()函數(shù): StandardButton QMessageBox::question (QWidget* parent, //消息框的父窗口指針const QString& title, //消息框的標(biāo)題欄const QString& text, //消息框的文字提示信息StandardButtons buttons=Ok, StandardButton defaultButton=No );?
QMessageBox類 question()函數(shù) 在cpp文件的開始部分添加頭文件: #include <QMessageBox> 在實(shí)現(xiàn)函數(shù)中添加如下代碼 if(QMessageBox::question(this,tr("Question消息框"),tr("您現(xiàn)在已經(jīng)修改完成,是否要結(jié)束程序?"),QMessageBox::Ok|QMessageBox::Cancel,QMessageBox::Ok) == QMessageBox::Ok) {; }?
?
?
QMessageBox類。 information()函數(shù): StandardButton QMessageBox::information (QWidget*parent, //消息框的父窗口指針const QString& title, //消息框的標(biāo)題欄const QString& text, //消息框的文字提示信息StandardButtons buttons=Ok, //同Question消息框的注釋內(nèi)容StandardButton defaultButton=NoButton // );?
?
QMessageBox類 information函數(shù) 在cpp文件的開始部分添加頭文件: #include <QMessageBox> 在實(shí)現(xiàn)函數(shù)中添加如下代碼 QMessageBox::information(this,tr("Information消息框"),tr("這是Information消息框測(cè)試,歡迎您!"));?
?
?
QMessageBox類。 warning()函數(shù): Warning消息框使用QMessageBox::warning()函數(shù)完成,函數(shù)形式如下: StandardButton QMessageBox::warning (QWidget* parent, //消息框的父窗口指針const QString& title, //消息框的標(biāo)題欄const QString& text, //消息框的文字提示信息StandardButtons buttons=Ok, //同Question消息框的注釋內(nèi)容StandardButton defaultButton=NoButton );?
QMessageBox類 warning函數(shù) 在cpp文件的開始部分添加頭文件: #include <QMessageBox> 在實(shí)現(xiàn)函數(shù)中添加如下代碼 if(QMessageBox::warning(this,tr("Warning消息框"),tr("您修改的內(nèi)容還未保存,是否要保存對(duì)文檔的修改?"),QMessageBox::Save|QMessageBox::Discard|QMessageBox::Cancel,QMessageBox::Save) == QMessageBox::Save) {; }?
QMessageBox類。 critical()函數(shù): Critical消息框使用QMessageBox::critical()函數(shù)完成,函數(shù)形式如下: StandardButton QMessageBox::critical (QWidget* parent, //消息框的父窗口指針const QString& title, //消息框的標(biāo)題欄const QString& text, //消息框的文字提示信息StandardButtons buttons=Ok, //同Question消息框的注釋內(nèi)容StandardButton defaultButton=NoButton ); QMessageBox類 critical函數(shù) 在cpp文件的開始部分添加頭文件: #include <QMessageBox> 在實(shí)現(xiàn)函數(shù)中添加如下代碼 QMessageBox::critical(this,tr("Critical消息框"),tr("這是一個(gè)Critical消息框測(cè)試!"));?
?
QMessageBox類。 about()函數(shù): About消息框使用QMessageBox::about()函數(shù)完成,函數(shù)形式如下: void QMessageBox::about (QWidget* parent, //消息框的父窗口指針const QString& title, //消息框的標(biāo)題欄const QString& text //消息框的文字提示信息 );?
QMessageBox類 about函數(shù) 在cpp文件的開始部分添加頭文件: #include <QMessageBox> 在實(shí)現(xiàn)函數(shù)中添加如下代碼 QMessageBox::about(this,tr("About消息框"),tr("這是一個(gè)About消息框測(cè)試!"));?
?
?
?
?
復(fù)制去Google翻譯翻譯結(jié)果轉(zhuǎn)載于:https://www.cnblogs.com/shichuan/p/4497908.html
總結(jié)
- 上一篇: Apache+Openssl
- 下一篇: 优化JS加载时间过长的一种思路