View Single Post
marxian's Avatar
Posts: 2,448 | Thanked: 9,523 times | Joined on Aug 2010 @ Wigan, UK
#6
Originally Posted by flotron View Post
i'm stuck with this errors:

main.cpp: In function 'int main(int, char**)':
main.cpp:16: error: 'view' was not declared in this scope


This is my main.cpp

Code:
#include <QtGui/QApplication>
#include "qmlapplicationviewer.h"
#include "scriptlauncher.h"
#include "qdeclarativecontext.h"

Q_DECL_EXPORT int main(int argc, char *argv[])
{
    QScopedPointer<QApplication> app(createApplication(argc, argv));

    QmlApplicationViewer viewer;
    viewer.setOrientation(QmlApplicationViewer::ScreenOrientationAuto);
    viewer.setMainQmlFile(QLatin1String("qml/untitled/main.qml"));
    viewer.showExpanded();

    ScriptLauncher launcher;
    QDeclarativeContext *context = view->rootContext();
    context->setContextProperty("scriptLauncher", &launcher);

    return app->exec();
}
'view' is the QDeclarativeView/QmlApplicationViewer, so in your case, it needs to be 'viewer.rootContext()' instead of 'view->rootContext()'.
__________________
'Men of high position are allowed, by a special act of grace, to accomodate their reasoning to the answer they need. Logic is only required in those of lesser rank.' - J K Galbraith

My website

GitHub

Last edited by marxian; 2012-10-26 at 00:39.
 

The Following 2 Users Say Thank You to marxian For This Useful Post: