Reputation: 1329
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();
}
Upvotes: 1
Views: 2983
Reputation: 478
Another source of this error can be linking to the wrong version of a Qt library - a release version for a debug build or vice versa.
Upvotes: 0
Reputation: 8147
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.
Upvotes: 1
Reputation: 8147
Assuming you are creating a QApplication
, make sure you're not statically allocating the object.
Don't do this
QWebView w;
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
w.show();
return a.exec();
}
Upvotes: 0
Reputation: 22272
You need to instantiate a QApplication
object in order to use any widget based class and it must be created first, so your main()
should look something like this..
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
QWebView w;
w.show();
return a.exec();
}
Upvotes: 0