昨天本来是回家想好好琢磨一下使用Chart来绘制曲线的,奈何在建立项目的时候也就卡住了,加上心情比较烦躁,也没有耐心寻找答案就草草了事。所以今天继续搞定这个。

Qt-QML-Charts-ChartView-编译错误-ASSERT: “!“No style available without QApplication!_Qml

上图是Qt 的编译错误截图


QML debugging is enabled. Only use this in a safe environment.
IGIESW d:\workspace\build-chareviewcurve-desktop_qt_5_8_0_msvc2015_64bit-debug\debug\chareviewcurve.exe found in whitelist: NOIGIWHW Game d:\workspace\build-chareviewcurve-desktop_qt_5_8_0_msvc2015_64bit-debug\debug\chareviewcurve.exe found in whitelist: NOIGIWHW Game d:\workspace\build-chareviewcurve-desktop_qt_5_8_0_msvc2015_64bit-debug\debug\chareviewcurve.exe found in whitelist: NOIGIWHW Game d:\workspace\build-chareviewcurve-desktop_qt_5_8_0_msvc2015_64bit-debug\debug\chareviewcurve.exe found in whitelist: NOASSERT: "!"No style available without QApplication!"" in file kernel\qapplication.cpp, line 1064
ASSERT: "!"No style available without QApplication!"" in file kernel\qapplication.cpp, line 1064A
程序异常结束。
D:\WorkSpace\build-ChareviewCurve-Desktop_Qt_5_8_0_MSVC2015_64bit-Debug\debug\ChareviewCurve.exe crashed.

这是错误的具体信息



其实就是两次建立工程的,昨天是手贱,手动选择建立quick2版本的QML工程,这样的工程在main.cpp中使用的和之前的是不一样的。


这是昨天的错误版的main.cpp


int main(int argc, char *argv[])
{
QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
QGuiApplication app(argc, argv);

QQmlApplicationEngine engine;
engine.load(QUrl(QLatin1String("qrc:/main.qml")));

return app.exec();
}

这是今天的main.cpp



int main(int argc, char *argv[])
{
QApplication app(argc, argv);

QQmlApplicationEngine engine;
engine.load(QUrl(QStringLiteral("qrc:/main.qml")));

return app.exec();
}

对比一下就发现了吧,


下面截图是今天的正确运行方式

Qt-QML-Charts-ChartView-编译错误-ASSERT: “!“No style available without QApplication!_Qt_02



剩下的东西等我有时间在写

​​