日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

标准对话框

發(fā)布時間:2025/5/22 编程问答 22 豆豆
生活随笔 收集整理的這篇文章主要介紹了 标准对话框 小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.
各種基本對話框通過調(diào)用各自不同的靜態(tài)函數(shù)來完成其功能,具體說明見表 標準文件對話框。 其函數(shù)形式如下: QString QFileDialog::getOpenFileName ( QWidget* parent=0, //標準文件對話框的父窗口const QString & caption=QString(), //標準文件對話框的標題名const QString & dir=QString(), //注(1)const QString & filter=QString(), //注(2)QString * selectedFilter=0, //用戶選擇的過濾器通過此參數(shù)返回Options options=0 //選擇顯示文件名的格式,默認是同時顯示目錄與文件名 )

?

?

創(chuàng)建一個標準文件對話框的詳細步驟: 在cpp文件的開始部分添加頭文件:

#include<QFileDialog>

在實現(xiàn)函數(shù)中添加如下代碼

QString s = QFileDialog::getOpenFileName(this,"open file dialog","/",?"C++ files(*.cpp)::C files(*.c)::Head files(*.h)");

?

標準顏色對話框。 其函數(shù)形式如下: getColor()函數(shù)是標準顏色對話框QColorDialog類的一個靜態(tài)函數(shù),該函數(shù)返回用戶選擇的顏色值,下面是getColor()函數(shù)形式: QColor getColor (const QColor& initial=Qt::white, //QWidget* parent=0 //標準顏色對話框的父窗口 );

?

?

創(chuàng)建一個標準文件對話框的詳細步驟: 在cpp文件的開始部分添加頭文件: #include <QColorDialog> 在實現(xiàn)函數(shù)中添加如下代碼 QColor c = QColorDialog::getColor(Qt::blue);

?

?

?

標準字體對話框。 其函數(shù)形式如下: getFont()函數(shù)是標準字體對話框QFontDialog類的一個靜態(tài)函數(shù),該函數(shù)返回用戶所選擇的字體,下面是getFont()函數(shù)形式: QFont getFont (bool* ok, //QWidget* parent=0 //標準字體對話框的父窗口 );

?

?

?

創(chuàng)建一個標準文件對話框的詳細步驟: 在cpp文件的開始部分添加頭文件: #include < QFontDialog> 在實現(xiàn)函數(shù)中添加如下代碼bool ok;QFont f = QFontDialog::getFont(&ok);if (ok){;}

?

?

?

QMessageBox類。 question()函數(shù): StandardButton QMessageBox::question (QWidget* parent, //消息框的父窗口指針const QString& title, //消息框的標題欄const QString& text, //消息框的文字提示信息StandardButtons buttons=Ok, StandardButton defaultButton=No );

?

QMessageBox類 question()函數(shù) 在cpp文件的開始部分添加頭文件: #include <QMessageBox> 在實現(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, //消息框的標題欄const QString& text, //消息框的文字提示信息StandardButtons buttons=Ok, //同Question消息框的注釋內(nèi)容StandardButton defaultButton=NoButton // );

?

?

QMessageBox類 information函數(shù) 在cpp文件的開始部分添加頭文件: #include <QMessageBox> 在實現(xiàn)函數(shù)中添加如下代碼 QMessageBox::information(this,tr("Information消息框"),tr("這是Information消息框測試,歡迎您!"));

?

?

?

QMessageBox類。 warning()函數(shù): Warning消息框使用QMessageBox::warning()函數(shù)完成,函數(shù)形式如下: StandardButton QMessageBox::warning (QWidget* parent, //消息框的父窗口指針const QString& title, //消息框的標題欄const QString& text, //消息框的文字提示信息StandardButtons buttons=Ok, //同Question消息框的注釋內(nèi)容StandardButton defaultButton=NoButton );

?

QMessageBox類 warning函數(shù) 在cpp文件的開始部分添加頭文件: #include <QMessageBox> 在實現(xiàn)函數(shù)中添加如下代碼 if(QMessageBox::warning(this,tr("Warning消息框"),tr("您修改的內(nèi)容還未保存,是否要保存對文檔的修改?"),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, //消息框的標題欄const QString& text, //消息框的文字提示信息StandardButtons buttons=Ok, //同Question消息框的注釋內(nèi)容StandardButton defaultButton=NoButton ); QMessageBox類 critical函數(shù) 在cpp文件的開始部分添加頭文件: #include <QMessageBox> 在實現(xiàn)函數(shù)中添加如下代碼 QMessageBox::critical(this,tr("Critical消息框"),tr("這是一個Critical消息框測試!"));

?

?

QMessageBox類。 about()函數(shù): About消息框使用QMessageBox::about()函數(shù)完成,函數(shù)形式如下: void QMessageBox::about (QWidget* parent, //消息框的父窗口指針const QString& title, //消息框的標題欄const QString& text //消息框的文字提示信息 );

?

QMessageBox類 about函數(shù) 在cpp文件的開始部分添加頭文件: #include <QMessageBox> 在實現(xiàn)函數(shù)中添加如下代碼 QMessageBox::about(this,tr("About消息框"),tr("這是一個About消息框測試!"));

?

?

?

?

?

復(fù)制去Google翻譯翻譯結(jié)果

轉(zhuǎn)載于:https://www.cnblogs.com/shichuan/p/4497908.html

總結(jié)

以上是生活随笔為你收集整理的标准对话框的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯,歡迎將生活随笔推薦給好友。