Qt 漂亮的Material样式对话框(QtMaterialDialog)


前言

  在实际项目开发中,对于漂亮美观的UI界面大多数都是采用样式表来实现的,但是实际上即使是样式表很少也能实现比较带科技炫酷的风格,本篇介绍的是模仿谷歌Material风格的UI界面,基于大牛的第三方开源控件库,界面效果大致如下

正文

我对接口进行了封装,关键代码献上:
头文件:

1 #ifndef FORM_H 2 #define FORM_H 3 4 #include <QWidget> 5 #include <QDebug> 6 #include <QThread> 7 #include <QLabel> 8 #include <QHBoxLayout> 9 10 namespace Ui 13 14 class QtMaterialRaisedButton; 15 class QtMaterialFlatButton; 16 class QtMaterialDialog; 17 18 class Form : public QWidget 19 ; 41 42 #endif // FORM_H

cpp文件:
两个关键函数,初始化窗口函数以及显示窗口函数

1 void Form::InitQtMaterialDialog() 2 ); 33 connect(yesButton,&QtMaterialFlatButton::pressed,[this]()); 37 } 38 39 } 40 41 void Form::ShowQtMaterialDialog(const QString &text, bool haveCancle) 42 ); 55 } 56 hButtonLayout>addWidget(cancleButton); 57 hButtonLayout>setStretch(0,1); 58 hButtonLayout>setStretch(1,1); 59 } 60 if(!haveCancle && hButtonLayout>indexOf(cancleButton) != 1) 61 66 m_dialog>showDialog(); 67 } 68 }



上一篇:Qt 获取程序编译时间

下一篇:Qt 文件模型(QFileSystemModel)详细介绍


Qt
Copyright © 2002-2019 k262电脑网 www.k262.cn 皖ICP备2020016292号
温馨提示:部分文章图片数据来源与网络,仅供参考!版权归原作者所有,如有侵权请联系删除!QQ:251442993 热门搜索 网站地图