我的Qt学习之路——标准对话框
来源:互联网 发布:spss数据显著性分析 编辑:程序博客网 时间:2024/06/06 03:03
所谓标准对话框,是 Qt 内置的一系列对话框,用于简化开发。
较为常用的内置对话框有:QColorDialog(选择颜色),QFileDialog(选择文件或者目录),QFontDialog(选择字体),QInputDialog(允许用户输入一个值,并将其值返回),QMessageBox(模态对话框),QPrintDialog(打印机配置)。
前一篇blog里实现了文本文件的读取和保存,能够实现了文本编辑器的部分功能,在txt文本编辑器里还能够设置选中文本的颜色以及字体,这里我们调用的是windows自带的QColorDialog和QFontDialog。
首先在mainwindow.h里声明字体设置和颜色设置两个槽函数
private slots: void setColorSlots(); void selectAllSlots();
然后在cpp文件中进行定义
void MainWindow::setFontSlots(){ bool ok; QFont font=QFontDialog::getFont(&ok,this); if(ok){ ui->textEdit->setFont(font); } else{ QMessageBox::information(this,"错误信息","无法获取当前字体"); return; }}void MainWindow::setColorSlots(){ QColor color=QColorDialog::getColor(Qt::green,this);//打开颜色设置框默认的是绿色 if(color.isValid()){ ui->textEdit->setTextColor(color); } else{ QMessageBox::information(this,"错误信息","无法获取颜色"); return; }}
阅读全文
0 0
- 我的Qt学习之路——标准对话框
- Qt学习之路(15): Qt标准对话框之QFileDialog
- Qt学习之路(16): Qt标准对话框之QColorDialog
- Qt学习之路(17): Qt标准对话框之QMessageBox
- Qt学习之路(18): Qt标准对话框之QInputDialog
- Qt学习之路(15): Qt标准对话框之QFileDialog
- Qt学习之路(16): Qt标准对话框之QColorDialog
- Qt学习之路(17): Qt标准对话框之QMessageBox
- Qt学习之路(18): Qt标准对话框之QInputDialog
- Qt学习之路(15): Qt标准对话框之QFileDialog
- Qt学习之路(16): Qt标准对话框之QColorDialog
- Qt学习之路(17): Qt标准对话框之QMessageBox
- Qt学习之路(18): Qt标准对话框之QInputDialog
- Qt学习之路(15): Qt标准对话框之QFileDialog
- Qt学习之路(16): Qt标准对话框之QColorDialog
- Qt学习之路(17): Qt标准对话框之QMessageBox
- Qt学习之路(18): Qt标准对话框之QInputDialog
- Qt学习之路(17): Qt标准对话框之QMessageBox
- 第九章 排序
- 从零开始搞懂Android网络请求——HttpURLConnection
- 51nod 1050 循环数组最大子段和
- 11.06 CSS的基础应用2
- 卡尔曼滤波学习心得(1)方程推导
- 我的Qt学习之路——标准对话框
- Node实现简单的表单+图片上传+路由
- 随机抽取名字
- 简单ioc模拟-使用工厂方法
- win10环境下,解决javac不是内部或外部命令
- HDU 1272 小希的迷宫
- Interactive Data Visualization for the Web, 2nd Edition.pdf 英文原版 免费下载
- java日常学习:异常和finally块
- 【Unity】图形渲染优化、渲染管线优化、图形性能优化