13#include <QtCore/QCoreApplication>
15#include <QtQml/QQmlEngine>
21 static QString adjustPath(
const QString &path);
24QString QtQuick2ApplicationViewerPrivate::adjustPath(
const QString &path)
27 if (!QDir::isAbsolutePath(path))
28 return QString::fromLatin1(
"%1/%2")
29 .arg(QCoreApplication::applicationDirPath(), path);
30#elif defined(Q_OS_MAC)
31 if (!QDir::isAbsolutePath(path))
32 return QString::fromLatin1(
"%1/../Resources/%2")
33 .arg(QCoreApplication::applicationDirPath(), path);
34#elif defined(Q_OS_BLACKBERRY)
35 if (!QDir::isAbsolutePath(path))
36 return QString::fromLatin1(
"app/native/%1").arg(path);
37#elif !defined(Q_OS_ANDROID)
38 QString pathInInstallDir =
39 QString::fromLatin1(
"%1/../%2").arg(QCoreApplication::applicationDirPath(), path);
40 if (QFileInfo(pathInInstallDir).exists()) {
41 return pathInInstallDir;
44 QString::fromLatin1(
"%1/%2").arg(QCoreApplication::applicationDirPath(), path);
45 if (QFileInfo(pathInInstallDir).exists()) {
46 return pathInInstallDir;
48#elif defined(Q_OS_ANDROID_NO_SDK)
49 return QLatin1String(
"/data/user/qt/") + path;
58 connect(engine(),
SIGNAL(quit()), SLOT(close()));
59 setResizeMode(QQuickView::SizeRootObjectToView);
69 d->mainQmlFile = QtQuick2ApplicationViewerPrivate::adjustPath(file);
70#if defined(Q_OS_ANDROID) && !defined(Q_OS_ANDROID_NO_SDK)
71 setSource(QUrl(QLatin1String(
"assets:/")+d->mainQmlFile));
73 setSource(QUrl::fromLocalFile(d->mainQmlFile));
79 engine()->addImportPath(QtQuick2ApplicationViewerPrivate::adjustPath(path));
84#if defined(Q_WS_SIMULATOR) || defined(Q_OS_QNX)
int SIGNAL(int pid, int signum)
void addImportPath(const QString &path)
QtQuick2ApplicationViewer(QWindow *parent=0)
void setMainQmlFile(const QString &file)
virtual ~QtQuick2ApplicationViewer()