Commit 88af981a authored by Alessandro Portale's avatar Alessandro Portale
Browse files

Fixing order of call to QDeclarativeView

setSource() needs to be called *after* addImportPath.
parent c424570a
......@@ -5,9 +5,10 @@ int main(int argc, char *argv[])
{
QApplication app(argc, argv);
QmlApplicationView qmlApp(QLatin1String("qml/app/app.qml")); // MAINQML
QmlApplicationView qmlApp;
qmlApp.addImportPath(QLatin1String("modules")); // ADDIMPORTPATH
qmlApp.setOrientation(QmlApplicationView::Auto); // ORIENTATION
qmlApp.setMainQml(QLatin1String("qml/app/app.qml")); // MAINQML
qmlApp.setLoadDummyData(false); // LOADDUMMYDATA
#ifdef Q_OS_SYMBIAN
......
......@@ -18,9 +18,20 @@ class QmlApplicationViewPrivate
{
QString mainQmlFile;
friend class QmlApplicationView;
static QString adjustPath(const QString &path);
};
QmlApplicationView::QmlApplicationView(const QString &mainQmlFile, QWidget *parent) :
QString QmlApplicationViewPrivate::adjustPath(const QString &path)
{
#ifdef Q_OS_MAC
if (!QDir::isAbsolute(path))
return QCoreApplication::applicationDirPath()
+ QLatin1String("/../Resources/") + path;
#endif
return path;
}
QmlApplicationView::QmlApplicationView(QWidget *parent) :
#ifdef QMLINSPECTOR
QmlViewer::QDeclarativeDesignView(parent)
#else
......@@ -28,13 +39,6 @@ QmlApplicationView::QmlApplicationView(const QString &mainQmlFile, QWidget *pare
#endif
, m_d(new QmlApplicationViewPrivate)
{
#ifdef Q_OS_MAC
m_d->mainQmlFile = QCoreApplication::applicationDirPath()
+ QLatin1String("/../Resources/") + mainQmlFile;
#else
m_d->mainQmlFile = mainQmlFile;
#endif
setSource(QUrl(m_d->mainQmlFile));
connect(engine(), SIGNAL(quit()), SLOT(close()));
setResizeMode(QDeclarativeView::SizeRootObjectToView);
}
......@@ -44,9 +48,15 @@ QmlApplicationView::~QmlApplicationView()
delete m_d;
}
void QmlApplicationView::setMainQml(const QString &mainQml)
{
m_d->mainQmlFile = QmlApplicationViewPrivate::adjustPath(mainQml);
setSource(QUrl::fromLocalFile(m_d->mainQmlFile));
}
void QmlApplicationView::addImportPath(const QString &importPath)
{
engine()->addImportPath(importPath);
engine()->addImportPath(QmlApplicationViewPrivate::adjustPath(importPath));
}
void QmlApplicationView::setOrientation(Orientation orientation)
......
......@@ -16,9 +16,10 @@ public:
Auto
};
QmlApplicationView(const QString &mainQmlFile, QWidget *parent = 0);
QmlApplicationView(QWidget *parent = 0);
virtual ~QmlApplicationView();
void setMainQml(const QString &mainQml);
void addImportPath(const QString &importPath);
void setOrientation(Orientation orientation);
void setLoadDummyData(bool loadDummyData);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment