You are not logged in.

Dear visitor, welcome to QtForum.org. If this is your first visit here, please read the Help. It explains in detail how this page works. To use all features of this page, you should consider registering. Please use the registration form, to register here or read more information about the registration process. If you are already registered, please login here.

1

Monday, January 9th 2012, 2:01pm

Cannot create QWebView object in Windows

I use the following snippet to create in a method a QWebView object:

if (NULL == qApp)
{
qDebug() << "qapp is NULL";
return QImage();
}
QWebView webView(qApp->activeWindow());//we need to recreate the view at each page

In Linux it works, but in Windows 7, using Qt 4.7.4, I get the following error:

"QWidget: must construct a QApplication before a QPain tDevice"
this is a fatal error generated by the condition NULL == qApp, but I don't see the reason since when the QWebView ctor is called qApp is not NULL.




2

Monday, January 9th 2012, 2:41pm

Without seeing more code, I can only suggest that the application is not constructed yet.

perhaps this will help: http://developer.qt.nokia.com/doc/qt-4.8/qimage.html . Please note the inherited member.
If you have a problem, CUT and PASTE your code. Do not retype or simplify it. Give a COMPLETE and COMPILABLE example of your problem. Otherwise we are all guessing the problem from a fabrication where relevant details are often missing.

3

Monday, January 9th 2012, 7:15pm

The application is too complex and it would be difficult to find a simpler example. That's why I have chosen to compare qApp against NULL, the QwebView constructor would be never reached if the qApp is not initialized.

4

Monday, January 9th 2012, 9:46pm

I have solved my problem. For some reason Qt VS plugin has inserted the debug versions of Qt libraries (QtNetwork4.lib and QtWebKit4.lib) in the release version of my application and this generated this odd behavior.

thank you for your help

Bogdan

5

Monday, January 9th 2012, 11:39pm

no, your problem is that when you return a QImage, you also make a QPaintDevice (by inheritance). You cannot make a QPaintDevice before a qApp.

By using the release versions (QtNetwork4.lib and QtWebKit4.lib ARE the release versions btw. The debug ones are QtNetworkd4.lib and QtWebKitd4.lib I think), you probably just removed that debug assert - not fixing the problem at all.

perhaps next time read what I said? ;)
If you have a problem, CUT and PASTE your code. Do not retype or simplify it. Give a COMPLETE and COMPILABLE example of your problem. Otherwise we are all guessing the problem from a fabrication where relevant details are often missing.

Similar threads

Used tags

QWebView, windows