QT关于图片打开,另存为,保存到指定位置操作
在头文件mainwindow.h中先声明以下类:
#include <QImage>
#include <QPixmap>
#include <QFileDialog>
#include <QMessageBox>
#include <QScreen>
#include <QGuiApplication>
在私有对象下声明这几个变量,用于存放文件夹地址。
/* 保存路径*/
QString runPath;
QString hglpName;
QString hglpPath;
再在设计界面上拖放一个标签和三个按钮,按钮分别命名为打开图片,另存为和保存。其中保存是保存到程序运行文件下的photo文件夹内。
主函数中关于
runPath = QCoreApplication::applicationDirPath(); //获取exe路径
hglpName = "photo";
hglpPat