Nope.
However, you could use this trick:
1) define a class (ResourceFile) that will copy a resource to disk (in the hard-coded "resources" directory at executable file level in this example)
#ifndef RESOURCEFILE_H
#define RESOURCEFILE_H
#include <QFile>
#include <QString>
class ResourceFile
: public QFile{
public:
};
#endif // RESOURCEFILE_H
#ifndef RESOURCEFILE_H
#define RESOURCEFILE_H
#include <QFile>
#include <QString>
class ResourceFile : public QFile
{
public:
ResourceFile (const QString &respath, QObject * parent = 0);
};
#endif // RESOURCEFILE_H
To copy to clipboard, switch view to plain text mode
#include "resourcefile.h"
#include <QFileInfo>
#include <QDir>
#define FILES_DIR "resources"
{
if (!files.cd(FILES_DIR))
{
files.mkdir(FILES_DIR);
files.cd (FILES_DIR);
}
setFileName (files.filePath(resource.fileName()));
if (!exists())
{
{
{
write(resfile.readAll());
close();
}
resfile.close();
}
}
}
#include "resourcefile.h"
#include <QFileInfo>
#include <QDir>
#define FILES_DIR "resources"
ResourceFile::ResourceFile (const QString & respath, QObject *parent)
: QFile (parent)
{
QFileInfo resource (respath);
QDir files = QDir::current();
if (!files.cd(FILES_DIR))
{
files.mkdir(FILES_DIR);
files.cd (FILES_DIR);
}
setFileName (files.filePath(resource.fileName()));
if (!exists())
{
QFile resfile(respath);
if(resfile.open(QIODevice::ReadOnly))
{
if (open(QIODevice::ReadWrite))
{
write(resfile.readAll());
close();
}
resfile.close();
}
}
}
To copy to clipboard, switch view to plain text mode
2) define a class (ResourceSound) that will plug QSound to the disk copy
#ifndef RESOURCESOUND_H
#define RESOURCESOUND_H
#include <QSound>
#include "resourcefile.h"
class ResourceSound
: private ResourceFile,
public QSound{
public:
: ResourceFile (respath, parent)
,
QSound (fileName
(), parent
) {}};
#endif // RESOURCESOUND_H
#ifndef RESOURCESOUND_H
#define RESOURCESOUND_H
#include <QSound>
#include "resourcefile.h"
class ResourceSound : private ResourceFile, public QSound
{
public:
ResourceSound (const QString & respath, QObject * parent = 0)
: ResourceFile (respath, parent)
, QSound (fileName(), parent) {}
};
#endif // RESOURCESOUND_H
To copy to clipboard, switch view to plain text mode
You can then use ResourceSound instead of QSound and get the same result (or lack of, considering the shortcomings of QSound ).
Bookmarks