1. change app save path coding.

This commit is contained in:
shouchih_chen 2024-09-14 16:55:57 +08:00
parent e8a4557906
commit 4c92f00cb2
3 changed files with 19 additions and 10 deletions

View File

@ -3,10 +3,13 @@
#include <QGraphicsScene> #include <QGraphicsScene>
#include <QGraphicsView> #include <QGraphicsView>
#include <QGraphicsRectItem> #include <QGraphicsRectItem>
#include <QCoreApplication>
#define BG_WIDTH 3508 #define BG_WIDTH 3508
#define BG_HEIGHT 2481 #define BG_HEIGHT 2481
struct NameInfo_t { struct NameInfo_t {
QString name1; QString name1;
QString name2; QString name2;

View File

@ -1,7 +1,6 @@
#include "customlogo2.h" #include "customlogo2.h"
#include "ui_customlogo2.h" #include "ui_customlogo2.h"
#include "def.h"
#include "QFileDialog"
#include <QMessageBox> #include <QMessageBox>
#include <QDateTime> #include <QDateTime>
@ -248,16 +247,16 @@ void customlogo2::saveToImage(const QString& filename, QGraphicsScene* scene)
QPainter painter(&image); QPainter painter(&image);
scene->render(&painter); scene->render(&painter);
#ifdef Q_OS_DARWIN
QString APP_PATH = QCoreApplication::applicationDirPath() + "/../../../";
#ifdef Q_OS_MAC
QString folder_name = QCoreApplication::applicationDirPath() + "/../../../export_" + QDateTime::currentDateTime().toString("yyyyMMdd");
qDebug() << "app director path" <<QCoreApplication::applicationDirPath();
#else #else
QString folder_name = QCoreApplication::applicationDirPath() + "/export_" + QDateTime::currentDateTime().toString("yyyyMMdd"); static QString APP_PATH = "";
#endif #endif
image.save(folder_name.append(filename), "JPEG"); QString save_path = APP_PATH.append(filename);
qDebug()<<"save path: "<< save_path;
image.save(save_path, "JPEG");
QByteArray imageData; QByteArray imageData;
QBuffer buffer(&imageData); QBuffer buffer(&imageData);

View File

@ -1,6 +1,13 @@
#ifndef DEF_H #ifndef DEF_H
#define DEF_H #define DEF_H
#include <QCoreApplication>
#define VERSION "v2.8.0" #define VERSION "v2.8.0"
#endif // DEF_H #endif // DEF_H