Showing posts with label fix error qt. Show all posts
Showing posts with label fix error qt. Show all posts

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);
...
}

Tuesday, October 15, 2019

[Fix QT] TLS initialization failed | QSslSocket::connectToHostEncrypted Fail

The solution of TLS initialization failed step by step:

1- Firstly you need to find your SSL version for your windows machine( SSL version strictly depends on QT versions) with this function:
#include <QCoreApplication>
#include <QDebug>
#include <QSslSocket> //To use QSslSocket Class

int main(int argc, char *argv[])
{
    QCoreApplication a(argc, argv);
    qDebug()<<QSslSocket::supportsSsl() << QSslSocket::sslLibraryBuildVersionString() << QSslSocket::sslLibraryVersionString();
    return a.exec();
}
Result: 
2- After that run your code and call the above function. It will print your required SSL version in application output. In my case, it was “OpenSSL 1.0.2p 14 Aug 2018” “” which may be different for all the users.
3- TLS initialization failed: Now Download the requires SSL libraries from the link given below:
In my case: I download openssl-1.0.2p-x64_86-win64.zip
4- Paste all the files/content of SSL folder (which you have extracted) into the  debug folder. for eg: In my case it is:
E:\QT\NebProject\NASA_Vision\build-NASA_Vision-Desktop_Qt_5_12_2_MSVC2015_64bit-Debug\debug
Ok...Done
Back to Top