62 lines
1.4 KiB
C++
62 lines
1.4 KiB
C++
#include "mainwindow.h"
|
|
#include "ui_mainwindow.h"
|
|
|
|
#include <QImageReader>
|
|
#include <QDebug>
|
|
#include <QMimeData>
|
|
#include <QMouseEvent>
|
|
|
|
MainWindow::MainWindow(QWidget *parent)
|
|
: QMainWindow(parent)
|
|
, ui(new Ui::MainWindow)
|
|
, m_filePath(R"(E:\16bit-raw-argb-affinityphoto.psd)")
|
|
{
|
|
ui->setupUi(this);
|
|
}
|
|
|
|
MainWindow::~MainWindow()
|
|
{
|
|
delete ui;
|
|
}
|
|
|
|
void MainWindow::dragEnterEvent(QDragEnterEvent *event)
|
|
{
|
|
if (event->mimeData()->hasUrls()) {
|
|
event->acceptProposedAction();
|
|
} else {
|
|
event->ignore();
|
|
}
|
|
|
|
return QMainWindow::dragEnterEvent(event);
|
|
}
|
|
|
|
void MainWindow::dropEvent(QDropEvent *event)
|
|
{
|
|
event->acceptProposedAction();
|
|
|
|
const QMimeData * mimeData = event->mimeData();
|
|
|
|
if (mimeData->hasUrls()) {
|
|
const QList<QUrl> &urls = mimeData->urls();
|
|
if (!urls.isEmpty()) {
|
|
m_filePath = urls.first().toLocalFile();
|
|
ui->label->setText(m_filePath);
|
|
}
|
|
}
|
|
}
|
|
|
|
void MainWindow::on_pushButton_clicked()
|
|
{
|
|
// 如果输出里有 psd 说明确实加载进去了
|
|
qDebug() << QImageReader::supportedImageFormats();
|
|
|
|
// 后面的文件改成 psd 文件的路径
|
|
QScopedPointer< QImageReader> ir(new QImageReader(m_filePath));
|
|
qDebug() << ir->canRead();
|
|
QImage read = ir->read();
|
|
if (read.isNull()) {
|
|
qDebug() << "read is null";
|
|
}
|
|
ui->label->setPixmap(QPixmap::fromImage(read));
|
|
}
|