Solved Charts crash my application
-
hi,
If i create a ChartView in QML and run my app it will crash with this error :ASSERT: "!"No style available without QApplication!"" in file kernel\qapplication.cpp, line 1051 Invalid parameter passed to C runtime function. Invalid parameter passed to C runtime function. ASSERT: "!"No style available without QApplication!"" in file kernel\qapplication.cpp, line 1051 Invalid parameter passed to C runtime function. Invalid parameter passed to C runtime function. C:/Users/zer/Documents/build-Test-Desktop_Qt_5_11_0_MinGW_32bit2-Debug/debug/Test.exe exited with code 3
Why ?
Qt_5_11_0_MinGW_32bit2
.qml
import QtQuick 2.10 import QtQuick.Window 2.10 import QtCharts 2.2 Window { visible: true width: 640 height: 480 title: qsTr("QChartCrash") ChartView { title: "chart" } }
.cpp
#include <QGuiApplication> #include <QQmlApplicationEngine> int main(int argc, char *argv[]) { QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling); QGuiApplication app(argc, argv); QQmlApplicationEngine engine; engine.load(QUrl(QStringLiteral("qrc:/main.qml"))); if (engine.rootObjects().isEmpty()) return -1; return app.exec(); }
.pro
QT += quick QT+= charts QT += widgets CONFIG += c++11 DEFINES += QT_DEPRECATED_WARNINGS SOURCES += main.cpp RESOURCES += qml.qrc qnx: target.path = /tmp/$${TARGET}/bin else: unix:!android: target.path = /opt/$${TARGET}/bin !isEmpty(target.path): INSTALLS += target
thx
-
Hi,
Replace your
QGuiApplication
with aQApplication
as the error message suggests. -
Thx SGaist