QT编程的QDialog对话框右上角的问号按钮如何取消呢
很简单,Qt::WindowFlags flags=Qt::Dialog;flags |=Qt::WindowCloseButtonHint;setWindowFlags(flags);
Qt 对话框按钮设置与取消:
程序中已给出解释:首先:.h 文件,#ifndef MESSAGEBOX_H,#define MESSAGEBOX_H,#include <QDialog>class QLabel ;class MessageBox : public QDialog。
{Q_OBJECT,public :MessageBox (QWidget *parent =0);public slots :void slotQuestion ();void slotInformation ();void slotWarning ();void slotCritical ();void slotAbout ();void slotAboutQt ();void slotCustom ();private :QLabel *label ;};#endif // MESSAGEBOX_H
其次:.cpp 文件#include "messagebox.h"#include <QtGui>MessageBox ::MessageBox (QWidget *parent ): QDialog (parent ) setWindowTitle (trUtf8("\345\257\271\350\257\235\346\241\206\345\255\246\344\271\240\347\244\272\344\276\213"));label = new QLabel ;
case QMessageBox ::Cancel :label ->setText (" Warning button / Cancel ");break;default :break ;}return ;}void MessageBox ::slotQuestion (){}void MessageBox ::slotInformation (){}void MessageBox ::slotCritical (){ }void MessageBox ::slotAbout (){}void MessageBox ::slotAboutQt (),后面的函数代码可以参照前面的,在此就不介绍。
setWindowFlags(flags&~Qt::WindowContextHelpButtonHint);
应该是windows10下,去掉那个问号按钮。怎么你们答非所问。
2015-06-29 · 知道合伙人软件行家
flags |=Qt::WindowCloseButtonHint;
setWindowFlags(flags);
我去试下
ok,绝对没问题,哈哈
setWindowFlags(windowFlags()& ~Qt::WindowContextHelpButtonHint);