提交 59f4ce96 编写于 作者: K khz-pc

00_Qt资源解析 相关代码

上级 24a63371
#include "mydll.h"
#include <QIcon>
#include <QPixmap>
#include <QMediaContent>
#include <QSound>
#include <QResource>
#include <QFile>
#include <fstream>
#include <QDir>
#include <Windows.h>
Mydll g_dll;
Mydll::Mydll()
{
// 测试一个icon
{
char *res = ":/new/prefix1/logo.ico";
QString localname = QString("D") + res;
QPixmap icon(res);
icon.save(localname);
}
return;
// 测试一组图片
{
char *res[] = {
":/toolbar/a.png",
":/toolbar/b.png",
":/toolbar/c.png",
":/picture/default.bmp",
":/status/x.png",
":/status/y.gif",
":/status/z.png",};
for(int i = 0; i < sizeof(res)/sizeof(char*); ++i)
{
break;
QString localname = QString("D") + res[i];
QPixmap icon(res[i]);
icon.save(localname);
}
}
return;
// 测试音频文件(失败了)
{
QFile fres("qrc:/media/audio/KD1.mp3");
QString msg = QString("khz%1---").arg(fres.exists());
OutputDebugStringA(msg.toLatin1().data());
QFile f("D:\\1.mp3");
// f.write((const char*)f.data(), res2.size());
}
/*
QMediaContent content("qrc:/media/audio/1.mp3");
QMediaResourceList reslist = content.canonicalResource();
QMediaResource res3 = reslist[0];
std::ofstream of2("D:\\100.mp3");
of2.write((const char*)res3.().data(), res3.dataSize());
return;
QResource res2(QString(":/media/audio/100.mp3"));
std::ofstream of("D:\\100.mp3");
of.write((const char*)res2.data(), res2.size());
return;*/
// QMediaContent content("qrc:/media/audio/1.mp3");
}
#ifndef MYDLL_H
#define MYDLL_H
#include "mydll_global.h"
class MYDLLSHARED_EXPORT Mydll
{
public:
Mydll();
};
#endif // MYDLL_H
#-------------------------------------------------
#
# Project created by QtCreator 2019-03-26T22:24:00
#
#-------------------------------------------------
QT += gui
QT += multimedia
TARGET = mydll
TEMPLATE = lib
DEFINES += MYDLL_LIBRARY
# The following define makes your compiler emit warnings if you use
# any feature of Qt which has been marked as deprecated (the exact warnings
# depend on your compiler). Please consult the documentation of the
# deprecated API in order to know how to port your code away from it.
DEFINES += QT_DEPRECATED_WARNINGS
# You can also make your code fail to compile if you use deprecated APIs.
# In order to do so, uncomment the following line.
# You can also select to disable deprecated APIs only up to a certain version of Qt.
#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0
SOURCES += \
mydll.cpp
HEADERS += \
mydll.h \
mydll_global.h
unix {
target.path = /usr/lib
INSTALLS += target
}
此差异已折叠。
#ifndef MYDLL_GLOBAL_H
#define MYDLL_GLOBAL_H
#include <QtCore/qglobal.h>
#if defined(MYDLL_LIBRARY)
# define MYDLLSHARED_EXPORT Q_DECL_EXPORT
#else
# define MYDLLSHARED_EXPORT Q_DECL_IMPORT
#endif
#endif // MYDLL_GLOBAL_H
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册