本文整理汇总了C++中QQmlApplicationEngine::offlineStoragePath方法的典型用法代码示例。如果您正苦于以下问题:C++ QQmlApplicationEngine::offlineStoragePath方法的具体用法?C++ QQmlApplicationEngine::offlineStoragePath怎么用?C++ QQmlApplicationEngine::offlineStoragePath使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QQmlApplicationEngine
的用法示例。
在下文中一共展示了QQmlApplicationEngine::offlineStoragePath方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
Q_DECL_EXPORT int main(int argc, char *argv[])
{
QGuiApplication app(argc, argv);
static QTranslator qmlTranslator;
QString uiLanguage = QLocale::system().name();
qDebug() << "load qml translation" << uiLanguage;
if(!qmlTranslator.load(uiLanguage,":/locale")) {
qDebug() << "cannot load translation ,trying another method"
<< QDir::currentPath() + "/locale/" + uiLanguage
<< qmlTranslator.load(QDir::currentPath() + "/locale/" + uiLanguage);
}
app.installTranslator(&qmlTranslator);
qmlRegisterType<FileIO>("FileIO", 1, 0, "FileIO");
QQmlApplicationEngine engine;
QQmlContext *context = engine.rootContext();
qDebug() << QStandardPaths::standardLocations(QStandardPaths::PicturesLocation);
QString firstPath = QStandardPaths::standardLocations(QStandardPaths::PicturesLocation).at(0);
engine.load(QUrl(QStringLiteral("qrc:/qml/main.qml")));
qDebug() << engine.offlineStoragePath();
PictureLibrary *pictures = new PictureLibrary();
pictures->setContext(context);
pictures->setLocation(QStandardPaths::PicturesLocation);
return app.exec();
}
示例2: returnCached
void CachedImage::returnCached(QUrl imgUrl)
{
QQmlApplicationEngine eng;
//Store the qml app offline storage location
//In android it's application path/files/QML/OfflineStorage/
m_localPath = QDir::fromNativeSeparators(eng.offlineStoragePath() + "\\");
if(m_folder != "")
m_localPath += m_folder + "/";
QDir dir(m_localPath);
if (!dir.exists()) {
if (!dir.mkpath(m_localPath)) {
qDebug() << "Couldn't create subdirectory";
return;
}
}
if(!QFile::exists(m_localPath + m_filename)) { // This check seems to be taking a long time to do for each file
//Create the request to be sent with Network Access Maanager
emit cacheLoaded(false);
QNetworkRequest req(imgUrl);
// Reply will contain header and data and emits signal finished()
// that will be listened by constructor connector
manager.get(req);
} else {
//qDebug() << "exists: " << m_localPath + m_filename;
//The file is already downloaded, let's just emit the local path
m_localUrl = "file:///" + m_localPath + m_filename;
emit cacheLoaded(true);
emit localsrcChanged();
}
}
示例3: main
int main(int argc, char *argv[])
{
#ifdef Q_OS_LINUX
// When using QAudioOutput on linux/ALSA, we need to
// block SIGIO on all threads except the audio thread
sigset_t set;
sigemptyset(&set);
sigaddset(&set, SIGIO);
pthread_sigmask(SIG_BLOCK, &set, nullptr);
#endif
qSetMessagePattern("[%{if-debug}D%{endif}%{if-warning}W%{endif}"
"%{if-critical}C%{endif}%{if-fatal}F%{endif}]"
"%{if-category} [%{category}]:%{endif} %{message}");
QGuiApplication a(argc, argv);
a.setApplicationName("Phoenix");
a.setApplicationVersion(PHOENIX_VERSION);
a.setOrganizationName("Phoenix");
// a.setOrganizationDomain("phoenix-emu.org");
QSettings settings;
qmlRegisterType<PhoenixWindow>("phoenix.window", 1, 0, "PhoenixWindow");
qmlRegisterType<CachedImage>("phoenix.image", 1, 0, "CachedImage");
qmlRegisterType<VideoItem>("phoenix.video", 1, 0, "VideoItem");
qmlRegisterType<GameLibraryModel>();
qmlRegisterType<PhoenixLibrary>("phoenix.library", 1, 0, "PhoenixLibrary");
qmlRegisterType<InputDeviceMapping>();
qmlRegisterType<InputDevice>();
qRegisterMetaType<retro_device_id>("retro_device_id");
qRegisterMetaType<int16_t>("int16_t");
qRegisterMetaType<InputDeviceEvent *>();
QQmlApplicationEngine engine;
// first, set the context properties
QQmlContext *rctx = engine.rootContext();
rctx->setContextProperty("inputmanager", &input_manager);
// then, load qml and display the window
engine.load(QUrl("qrc:/qml/main.qml"));
QObject *topLevel = engine.rootObjects().value(0);
PhoenixWindow *window = qobject_cast<PhoenixWindow *>(topLevel);
window->setCacheDirectory(engine.offlineStoragePath() + "/");
window->show();
input_manager.scanDevices();
return a.exec();
}