views:

374

answers:

5

I want to embed qtwebkit in my pure c windows GUI application.

Are there any examples, sample code on how to do this or is it just not possible? I know its very easy to do inside a QT application but I want to keep my development in C (which can be compiled with a free c compiler).

(searched google for several days without any luck).

+1  A: 

As of QT4, all Widgets require an initialized and running QApplication object - which dispatches both the os events, AND QT events needed to keep QT widgets running.

It looks like it may be possible to create a custom subclass QApplication, that would be instantiated (in order for QWebKit or other widgets) so that the singleton exists, and then call into it from your applications message loop - or perhaps even just a timer sent to your window - and get it to dispatch any QEvents it has queued.

I havn't tried it, but I have a similar need to use WebKit in an existing windows app, and it seems to be QWebKit, or this thing

Chris Becke
well thats what I sort of tried to do...have a look at this: http://www.qtforum.org/article/31506/embed-qwebview-into-win32-window-whole-window.html?highlight= (note im not a good programmer :-(
sonu
Your problem in that forum post is simple - QWinWidget doesn't have a setCentralWidget method. The only thing a QWinWidget is good for is being a parent of another Widget.So, QWinWidget* win = new QWinWidget(parent); QWebView* web = new QWebView(win);should get you your webview hosted in a windows window
Chris Becke
ok i done that but the problem now is that because i am creating a widget I need to create a QApplication instance in the DLL. The problem with that is it blocks the windows host application from working cause QApplication starts its own message loop. Any help? thanks.
sonu
That is the hard part unfortunately: You need to look at QApplication, potentially create a QModelessApplication derived from QApplication that does NOT have a run method, but does have a CallMeFrequently() method that you, well, call frequently, to execute the inner loop logic of QApplication::run, to ensure that QT events are being dispatched. I havn't done this yet. Im still hoping I can get WebKit working without Qt. So I can't comment on how hard it will be to get right. And whether doing so will keep you in compliance with the lgpl terms.
Chris Becke
i see...thats why theres not many examples of using webkit "the easy way".....oh well, i will leave it someone else to come up with a solution...thanks for your help Chris.
sonu
although this seems promising...http://www.kirix.com/labs/wxwebconnect.html
sonu
A: 

Build yourself an ActiveX control using ActiveQt. It's easy. Then embed that. Qt even knows how to pull IDispatch objects into its meta-object system, which in turn lets you expose them to your javascript context. It's really quite slick.

I'm doing exactly this in my current project. I'll try to open source it, to save other people the work, but it's not likely to be allowed.

Russell Mull
i am pretty sure you are saying that using activeQT you can embed Microsoft Internet Explorer? right? no thanks. That means IE must installed on the users computer or the user must install it. With wxWebConnect you distribute the whole gecko package and it doesn't need installing!!
sonu
A: 

yep...wxwidgets is definitely better than QT (in my opinion). The wxWebConnect embeds the gecko browser control pretty good.

Definitely do try http://www.kirix.com/labs/wxwebconnect.html

P.S. If you're wondering what project I am working on, check it out at http://www.viewerforphp.sourceforge.net (a program to run php pages without using a server package such as uniserver, WAMP etc).

sonu
A: 

You can consider http://www.twotoasts.de/index.php?/pages/midori_summary.html It is pure C web browser, what have used WebKit (not QtWebKit) Probably, it's may be helpfull for you)

Jamon
yeah, thats pretty good but its not anywhere near stable as wxWebConnect control. For example, try opening gmail or youtube in midori....
sonu
A: 

or if you want to embed google chrome try http://www.khrona.com/products/awesomium/

sonu