リチャードが言ったように、これは引用サンプルアプリから直接です
void CustomSqlDataSource::copyFileToDataFolder(const QString fileName)
{
// Since we need read and write access to the file, it has
// to be moved to a folder where we have access to it. First,
// we check if the file already exists (previously copied).
QString dataFolder = QDir::homePath();
QString newFileName = dataFolder + "/" + fileName;
QFile newFile(newFileName);
if (!newFile.exists()) {
// If the file is not already in the data folder, we copy it from the
// assets folder (read only) to the data folder (read and write).
QString appFolder(QDir::homePath());
appFolder.chop(4);
QString originalFileName = appFolder + "app/native/assets/" + fileName;
QFile originalFile(originalFileName);
if (originalFile.exists()) {
// Create sub folders if any creates the SQL folder for a file path like e.g. sql/quotesdb
QFileInfo fileInfo(newFileName);
QDir().mkpath (fileInfo.dir().path());
if(!originalFile.copy(newFileName)) {
qDebug() << "Failed to copy file to path: " << newFileName;
}
} else {
qDebug() << "Failed to copy file data base file does not exists.";
}
}
mSourceInDataFolder = newFileName;
}