PDA

View Full Version : Embed QWebView into non-QT Win32 window (whole window)



sonusingh
29th January 2010, 11:40
hi,

i am not really a programmer but prefer to learn new stuff rather than just waste time playing online games.

anyway i done a bit searching and found winmigrate (http://doc.trolltech.com/solutions/qtwinmigrate/winmigrate-walkthrough.html).

I have a win32 application compiled in pure c and a DLL created with QT (http://get.qt.nokia.com/qt/solutions/lgpl/qtwinmigrate-2.8_1-opensource.zip)

I edited the file main.cpp that looks like this:


#include <qmfcapp.h>
#include <qwinwidget.h>
#include <QtGui/QMessageBox>
#include <windows.h>
#include <QtGui/QMainWindow>
#include <QtWebKit/QWebView>

BOOL WINAPI DllMain( HINSTANCE hInstance, DWORD dwReason, LPVOID /*lpvReserved*/ )
{
static bool ownApplication = FALSE;

if ( dwReason == DLL_PROCESS_ATTACH )
ownApplication = QMfcApp::pluginInstance( hInstance );
if ( dwReason == DLL_PROCESS_DETACH && ownApplication )
delete qApp;

return TRUE;
}


extern "C" __declspec(dllexport) bool showDialog( HWND parent )
{
QWebView *browser;
browser = new QWebView();
QWinWidget *w = new QWinWidget(parent, 0, 0);

w->setCentralWidget(browser);
browser->load(QUrl("http://www.google.com.au/"));

return TRUE;
}

When i try to compile it i get the error:


C:/Users/pavitar/Desktop/qtwinmigrate-2.8_1-opensource/qtwinmigrate-2.8_1-opensource/examples/qtdll/./main.cpp:73: error: 'setCentralWidget' : is not a member of 'QWinWidget'

I suppose the question is it possible to embed the WebKit browser into a an external non-QT win32 application? All i can gather from the error is that QWidgets don't have a property named setcentralwidget() only QMainWindow does?! How to can I make the HWND into a QMainWindow?

Sorry for bad english (and programming knowledge)!