Search code examples
qtqwidgetqwebview

QWebView - QWidget: must construct a QApplication before a QPaintDevice error


Whenever I try to create a new QWebView, the post-build error is

QWidget: Must construct a QApplication before a QPaintDevice

why is this happening?

Yes, i did add QT += webkit to the pro file, and it says here

In qwtconfig.pri

CONFIG += QwtDll this line must be ->

#CONFIG += QwtDll

where is qtwconfig.pri?

FWI i'm on a static build

Here is main()

#include "MyWidget.h"
#include <QPlastiqueStyle>
#include <QtPlugin>
#include <QtWebKit/QWebView>
Q_IMPORT_PLUGIN(qico)


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

QApplication app(argc, argv);

app.setStyle(new QPlastiqueStyle);
app.setFont(QFont("Calibri"));
MyWidget widget;
widget.show();

QWebView w;
    w.show();

return app.exec();

}


Solution

  • The documentation mentions Webkit may not work as a static library.

    From the Platform and Compiler Notes page:

    WebKit is only supported as a dynamically built library. Static linkage is not supported.

    Try dynamic linking instead.