Qt Quick 5.7 ERROR "No style available without QApplication "
-
@jpnurmi Yes, I did, but i have got this error "fatal error C1083: Cannot open include file: 'QApplication': No such file or directory". This error i've got at windows 10, tonight try ubuntu.
main.cpp
#include <QApplication>
#include <QQmlApplicationEngine>int main(int argc, char *argv[])
{
QApplication app(argc, argv);QQmlApplicationEngine engine; engine.load(QUrl(QStringLiteral("qrc:/main.qml"))); return app.exec();
}
pro file
TEMPLATE = app
QT += widgets qml quick charts
CONFIG += c++11
SOURCES += main.cpp
RESOURCES += qml.qrc
include(deployment.pri) -
This is my .pro file;
TEMPLATE = app QT += widgets qml quick charts CONFIG += c++11 SOURCES += main.cpp RESOURCES += qml.qrc # Additional import path used to resolve QML modules in Qt Creator's code model QML_IMPORT_PATH = # Default rules for deployment. include(deployment.pri)
This is my main.cpp;
#include <QApplication> #include <QQmlApplicationEngine> int main(int argc, char *argv[]) { QApplication app(argc, argv); QQmlApplicationEngine engine; engine.load(QUrl(QStringLiteral("qrc:/main.qml"))); return app.exec(); }
This is my .qml file
import QtQuick 2.0 import QtCharts 2.0 ChartView { width: 400 height: 300 theme: ChartView.ChartThemeBrownSand antialiasing: true PieSeries { id: pieSeries PieSlice { label: "eaten"; value: 94.9 } PieSlice { label: "not yet eaten"; value: 5.1 } } }
and i get the same error , I don't know how to solve it
-
@Rivonsen said in Qt Quick 5.7 ERROR "No style available without QApplication ":
QApplication
Have you tried using
QGuiApplication
, which you should use when not dealing with widgets?int main(int argc, char *argv[]) { QGuiApplication app(argc, argv); QQmlApplicationEngine engine; engine.load(QUrl(QStringLiteral("qrc:/main.qml"))); return QGuiApplication::exec(); }
With project file:
TEMPLATE = app QT += core gui qml quick charts CONFIG += c++11 SOURCES += main.cpp RESOURCES += qml.qrc