首页 > 编程知识 正文

qt颜色对话框,qt对话框有时关闭不了

时间:2023-05-03 15:27:31 阅读:24262 作者:2927

一般对话框和q小部件看起来没有什么区别,但有区别

1 .在模式对话框、模式对话框中,exec有自己的消息吉鲁组; 然后循环传递了APP的信息; 也就是说,在显示此对话框时,不能单击其他窗口部件。

如果在exec中显示诊断程序,则可以在接受或拒绝中关闭窗口

如果诊断程序在显示中显示,则可以在关闭中关闭窗口。 这和q构件一样

有很多特殊的诊断程序;打印预览,文件选择,messagebox, 颜色选择,字体选择,打印;//所有这些对话框都是系统对话框

3 .相同之处均包括可以在部件上用QPainter绘制;

mydialog.h

# ifndef my dialog _ h # define my dialog _ h # includeqdialogclassmydialog 3360 publicqdialog { q _ object public 3360 explicit my volog QString _strDir; //打开的目录,如果可用,则包含当前项目的文件夹signals :公共slots 3360 voidslotbuttonclick (); (; #endif //MYDIALOG_H

mydialog.cpp

# include ' my dialog.h ' # includeqpushbutton # includeqdebug # includeqfiledialog//文件对话框# includeqfileinfo # includeqfo 颜色选择对话框#include QFontDialog//字体对话框#include QMessageBox//消息对话框# includeqpaintermydialog 33603360 my诊断程序(q www 蓝牙设置几何(150、100、80、30 ); 连接(button,signal ) clicked )、this,slot (slot button click ) ); } void my dialog :3360 slot button click () {#if 0 QDialog *dig=new QDialog ); int ret; qushbutton * button=newq push button (dig ); //connect(Button,signal ) clicked )、dig,slot (accept ) ); 发送接受信号(窗口连接(button,signal ) clicked )、dig,slot (reject ) )//接受信号,关闭窗口//diaject 如果在显示中显示诊断程序,则可以在关闭中关闭窗口。 这与q构件相同; 有很多特殊的诊断程序; 打印预览、文件选择、消息盒、颜色选择、字体选择、打印; //所有这些对话框都是系统对话框*/ret=dig-exec (; if (ret==q诊断:3360 accepted ) { qDebug () ' accepted '; (if ) ret==qdialog:Rejected ) { qDebug ) ' rejected '; (} //dig.exec ); //在模式对话框、模式对话框中,exec有自己的消息吉鲁组; 然后循环传递了APP的信息; 用于保存#endif#if 0 //文件的对话框qstring filename=qfiledialog :3360 get savefilename (null,' select a file to save ',_ stave ) # endif # if0 qstring filename=qfiledialog 33603360 get open filename (null,' select a directory to open ',_strDir,' png fileng filenarename ) 未选择if(filename.isempty () ) return; } qDebug () filename endl; qileinfofileinfo (文件名); _strDir=fileInfo.filePath (; # endif # if0qcolordialogcolordialog; colorDialog.exec (; qcolorcolor=color dialog.selected color (; q调试() color; # endif # if0qfontdialogfontdialog; 字体诊断. exec (; qfont font=font dialog.selected font (; q调试) )字体; # endif # if0 qmessagebox :3360 warning (this、' Error '、' Error mesg . ' ); # endif # if0 qmessagebox :3360关键(this、'关键'、'关键错误. ); # endifintret=qmessagebox :3360 question (this、' this '、' realy do .qmessagebox 33603360 yes|qmessagebox 336000/(if ) ret==qmessagebox :3360是) { qDebug () ' yes ); (if ) ret==qmessagebox :3360 yestoall ) qdebug(('yestoall ); }/*绘制诊断部件时,与小部件相同的*/void my诊断:3360绘制事件(qpaintevent ) (qpainterp ) this ); p.setpen(Qt:3360red; p.drawline (qpointf (10,10 )、qpointf (50,50 ); p.setbrush(Qt:3360yellow; p.Drawrect(qrect ) 100、140、200、200 ); } # includeqapplicationintmain (int argv,char *argv[] ) qapplication app (argc,argv ); 我的诊断程序d; d .设置几何(400、300、400、400 ); d.show (; app.exec (; }

1 .新建对话框

2 .保存文件对话框

3 .打开文件对话框

4 .颜色选择对话框

5 .字体选择对话框

6 .警告提示对话框

7 .严重错误警告

8 .咨询对话框

用QPainter绘制的窗口(一条线,一个矩形) )。

版权声明:该文观点仅代表作者本人。处理文章:请发送邮件至 三1五14八八95#扣扣.com 举报,一经查实,本站将立刻删除。