QML "ChartView" crashing app
Solved
QML and Qt Quick
-
Hey, I want to use ChartView to show statistics, but when trying to run my app just crashing. I heard about replacing QGuiApplication to QApplication, is it possible? I want QtQuick / QML, not QWidgets.
:-1: error: Debugger encountered an exception: Exception at 0x3d34d8, code: 0xc0000005: read access violation at: 0x0, flags=0x0 (first chance)
-
@BD9a As stated in https://doc.qt.io/qt-5/qapplication.html
You needQT += widgets
-
@JonB Nope, "QApplication file not found". My .pro file have this:
QT += quick QT += quickcontrols2
main.cpp
#include <QApplication> #include <QQmlApplicationEngine> #include <QQmlContext> #include <Building/building.h> #include <Clicking/clicking.h> #include <Keytranslator/keytranslator.h> #include <Conf/conf.h> int main(int argc, char *argv[]) { QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling); QGuiApplication app(argc, argv); QQmlApplicationEngine engine; Building building; Clicking clicking; KeyTranslator ktr; Conf config; building.config = &config; clicking.config = &config; config.create(); building.loopStart(); clicking.loopStart(); QQmlContext *ctx = engine.rootContext(); ctx->setContextProperty("Building", &building); ctx->setContextProperty("Clicking", &clicking); ctx->setContextProperty("keyTranslator", &ktr); ctx->setContextProperty("Config", &config); engine.rootContext()->setContextProperty("applicationDirPath", QGuiApplication::applicationDirPath()); engine.load(QUrl(QStringLiteral("qrc:/main.qml"))); if (engine.rootObjects().isEmpty()) return -1; return app.exec(); }
-
@BD9a As stated in https://doc.qt.io/qt-5/qapplication.html
You needQT += widgets