Sunday, October 20, 2019

[ Fix QT Creator ] ASSERT: "!"No style available without QApplication!"" in file kernel\qapplication.cpp

Error (windows and ubuntu with last qt 5.7). I created qt quick 2 controls app, add chart 2d bar and try run project, but I've got an error.

File main.c 

#include <QGuiApplication>
#include <QQmlApplicationEngine>

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

    QGuiApplication app(argc, argv);
...
}

How to Fix it???

Easy to Fix... 

Maybe in this version,It doesn't support QGuiApplication.. 

So,you have to instead use QApplication..

1. Add widgets to file .pro to use QApplication
QT += quick widgets

2. in main.c change to use QApplication

#include <QApplication>
#include <QQmlApplicationEngine>

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

No comments:

Post a Comment

Back to Top