YARP
Yet Another Robot Platform
 
Loading...
Searching...
No Matches
main.cpp
Go to the documentation of this file.
1/*
2 * SPDX-FileCopyrightText: 2006-2021 Istituto Italiano di Tecnologia (IIT)
3 * SPDX-License-Identifier: GPL-3.0-or-later
4 */
5
6#include <QtGui/QGuiApplication>
7#include "qtquick2applicationviewer.h"
8#include "config.h"
9
10#include <QQmlApplicationEngine>
11#include <QQuickWindow>
12#include <QtWidgets/QApplication>
13#include <QQmlContext>
14#include <QVariant>
15#include <QDir>
16
22int main(int argc, char *argv[])
23{
24#if QT_VERSION >= QT_VERSION_CHECK(5, 6, 0)
25 QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
26#else
27 qputenv("QT_DEVICE_PIXEL_RATIO", QByteArray("auto"));
28#endif
29 QApplication app(argc, argv);
30
31 QVariant retVal;
32
33 // De-comment this to trace all imports
34 /*QByteArray data = "1";
35 qputenv("QML_IMPORT_TRACE", data);*/
36
37 QQmlApplicationEngine engine;
38 engine.addImportPath(QDir::cleanPath(QCoreApplication::applicationDirPath() + QDir::separator() +
39 PLUGINS_RELATIVE_PATH));
40#ifdef CMAKE_INTDIR
41 engine.addImportPath(QDir::cleanPath(QCoreApplication::applicationDirPath() + QDir::separator() +
42 ".." + QDir::separator() +
43 PLUGINS_RELATIVE_PATH + QDir::separator() +
44 CMAKE_INTDIR));
45#endif
46 engine.load(QUrl("qrc:/qml/QtYARPScope/main.qml"));
47 QObject *topLevel = engine.rootObjects().value(0);
48 auto* window = qobject_cast<QQuickWindow *>(topLevel);
49
50 // Pack the argc and argv to a QStringList so we can pass them easily to the plugin
51 QStringList params;
52 for(int i=0;i<argc;i++){
53 params.append(argv[i]);
54 }
55 // Call the parseParameters of the toplevel object
56 QMetaObject::invokeMethod(topLevel,"parseParameters",
57 Qt::DirectConnection,
58 Q_RETURN_ARG(QVariant, retVal),
59 Q_ARG(QVariant,params));
60 if(!retVal.toBool()){
61 return 1;
62 }
63
64 window->show();
65
66 return (app.exec()!=0?1:0);
67}
int main(int argc, char *argv[])
Definition main.cpp:385