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

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 人文社科 > 生活经验 >内容正文

生活经验

Qt msgBox 快捷版

發布時間:2023/11/27 生活经验 31 豆豆
生活随笔 收集整理的這篇文章主要介紹了 Qt msgBox 快捷版 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

使用

1 int iRet = msgBox(pos, tr("警告")
2                       , tr("確定要刪除當前選中的行嗎?")
3                       , tr("確定"), tr("取消"), 1, 1);
4     if (1 == iRet) return;  // 0:確定 1:取消

?

?

實現

 1 //在指定的點topLeft 顯示 MessageBox
 2 int msgBox(const QPoint& topLeft
 3         , const QString &title
 4         , const QString &text
 5         , const QString &button0
 6         , const QString &button1
 7         , const int &defaultButton
 8         , const int &escapeButton
 9         , QMessageBox::Icon icon
10         , QWidget *parent)
11 {
12     QMessageBox msg(icon, title, text, QMessageBox::NoButton, parent
13                     , Qt::WindowStaysOnTopHint | Qt::Dialog | Qt::MSWindowsFixedSizeDialogHint);
14 
15     QPushButton* pBtn0 = NULL;
16     QPushButton* pBtn1 = NULL;
17 
18     pBtn0 = msg.addButton(button0, QMessageBox::NoRole);   //id = 0
19     if (!button1.isEmpty())
20     {
21         pBtn1 = msg.addButton(button1, QMessageBox::NoRole);   //id = 1
22     }
23 
24     if (defaultButton == 0) msg.setDefaultButton(pBtn0);
25     if (!button1.isEmpty())
26     {
27         if (defaultButton == 1) msg.setDefaultButton(pBtn1);
28     }
29 
30     if (escapeButton == 0) msg.setEscapeButton(pBtn0);
31     if (!button1.isEmpty())
32     {
33         if (escapeButton == 1) msg.setEscapeButton(pBtn1);
34     }
35 
36     if (topLeft.x() >= 0 && topLeft.y() >= 0) msg.move(topLeft);
37 
38     return msg.exec();  //返回用戶點擊的 按鈕的 id
39 }

?

?

?

轉載于:https://www.cnblogs.com/lt47/p/5885242.html

總結

以上是生活随笔為你收集整理的Qt msgBox 快捷版的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。