Registering a Callback for JS functions!?

Koos Vriezen koos.vriezen at xs4all.nl
Wed Feb 15 16:50:10 GMT 2006


On Wed, Feb 15, 2006 at 07:55:27AM -0800, Amr Ramadan wrote:
> Is this scenario possible in any means? I want to create an application
> which uses KHTML to display a page created after querying a local database
> server. Let us assume this page has several buttons, and each button is
> associated with an identification number. What I want is, when some button
> is pressed, the application will get notified with this action, along with
> the identification number associated, so that it would query the database,
> create a new page and display it.
> 
> Is this way of calling the application from within the HTML document, or
> making the application watch the document and replace some actions, in any
> way possible!?
> 
> If not, I can probably pass the ID in a POST request, but still, this would
> require that there would be a way for the application to get notified there
> is any attempt to open some file so that it would cancel such request and do
> its query based on the ID in the attempted path!!

You could of course build a http server in your application (eg.
something like http://localhost:8080), using either POST or XMLHttpRequest.

You could also try is using the Qt hierarchy of the khtml widget and connect
to QButton's click signal.

Or use a plugin's for that. That does require a registered mimetype (eg.
application/x-your-app). JS can use liveconnect talking to the plugin, the
plugin can use some global static (long time ago I posted an example for
this ( http://www.xs4all.nl/~jjvrieze/ktictactoe.tar.bz2 )

Note, last two examples assume application and khtml widget are in the
same process space.

I guess the second option is the most easiest. First one is easy too,
but requeres an more insecure network socket. And third is the hardest,
but has the advantage that you can create your own widgets.

Koos




More information about the kfm-devel mailing list