发布网友 发布时间:2022-04-21 23:52
共4个回答
热心网友 时间:2023-06-21 15:38
很简单,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 (),后面的函数代码可以参照前面的,在此就不介绍。
热心网友 时间:2023-06-21 15:39
Qt::WindowFlags flags= this->windowFlags();
setWindowFlags(flags&~Qt::WindowContextHelpButtonHint);
应该是windows10下,去掉那个问号按钮。怎么你们答非所问。
热心网友 时间:2023-06-21 15:39
Qt::WindowFlags flags=Qt::Dialog;
flags |=Qt::WindowCloseButtonHint;
setWindowFlags(flags);
热心网友 时间:2023-06-21 15:40
在构造函数中
setWindowFlags(windowFlags()& ~Qt::WindowContextHelpButtonHint);