QT打印窗口、退出、设置字体及颜色、设置时间、控件实现系统函数、添加资源文件(菜单图片)、工具栏添加图片
生活随笔
收集整理的這篇文章主要介紹了
QT打印窗口、退出、设置字体及颜色、设置时间、控件实现系统函数、添加资源文件(菜单图片)、工具栏添加图片
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
打印窗口
#include <QPrintDialog>
?
退出
QObject::connect(ui->exitAction, SIGNAL(triggerd()), this, SLOT(close()));?
設置字體及顏色
#include <QFontDialog> #include <QFont> #include <QColor> #include <QColorDialog>//設置字體 bool ok; QFont font = QFontDialog::getFont(&ok, this); if (ok) {ui->textEdit->setFont(font); } else {return; }//設置顏色 QColor color = QColorDialog::getColor(Qt::red, this); if (color.isVaid()) {ui->textEdit->setTextClose(color); } else {return; }?
設置時間
#include <QDateTime>QDateTime current = QDateTime::currentDateTime(); //獲取當前時間 QString strTime = current.toString("yyyy-M-dd hh:mm:ss"); ui->textEdit->append(time);?
控件實現系統函數
QObject::connect(ui->copyAction, SIGNAL(triggerd()), ui->textEdit, SLOT(cope()));?
添加資源文件(菜單圖片)
右鍵工程 -> File -> add new(添加新文件)
先添加前綴,后添加文件?
全選
右鍵菜單 -> edit
?
工具欄添加圖片
直接將菜單欄圖片拖至工具欄
新人創作打卡挑戰賽發博客就能抽獎!定制產品紅包拿不停!總結
以上是生活随笔為你收集整理的QT打印窗口、退出、设置字体及颜色、设置时间、控件实现系统函数、添加资源文件(菜单图片)、工具栏添加图片的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: sqlmap使用方法
- 下一篇: ‘map’ does not name