PDA

View Full Version : Can we Call a QT Function(VC++) instead of JavaScript function in an HTML page? How?



danish.ahmed
2nd August 2012, 05:39
I want customize my documentation containing html pages and to display them in QT Assistant. I need to implement a function on all the html pages which looks for a particular file in local drive and determine whether it is present or not?

I was thinking of implementing this functionality using Qt code. Is there a possibility that we could use Qt function written in VC++ instead of a javascript function to perform the mentioned task?

I have a little knowledge of html and javascript. But, i have tried a javascript function too but it just didn't get called when implemented and assistant is invoked from command line.

Thanks In Advance. Please comment.

ChrisW67
2nd August 2012, 06:18
You can expose QObject properties, slots and signals in the QtWebKit browser scripting environment using The QtWebKit Bridge. Qt Assistant uses this browser component but you would have to make a modified version of Assistant in order to plug in and expose your functionality. (Not sure if the compiled docs support JavaScript at all though)

Why does documentation need to know about files outside the docs?

danish.ahmed
2nd August 2012, 06:50
Thanks Chris for your suggestion i will go through the QTWebKit and QTWebKit Bridge Documentation. Meanwhile, if you can provide me some example regarding the same that would be great.

I want that function to first look for a requested file(currently opened html) in local drive at a specific location and if it is present there i will open it locally otherwise it would be downloaded from the server. So, that user wouldn't have to bother for internet access everytime he reads the documentation.

If there are any other easy way to implement it. please keep your comments coming. Thanks in Advance.

ChrisW67
2nd August 2012, 07:16
You are talking about your docs being a bunch-o-files in a folder on the disc: this is not the same as Qt Assistant in which all the pages are shipped in one Sqlite database.

You can do this using a handler for a custom url scheme handler (e.g. docs://... rather than http://) for a QNetworkAccessManager you attach to your browser component. I expect this is how the qrc:// scheme and Assistant's qthelp:// is done. See http://doc.qt.nokia.com/qq/32/qq32-webkit-protocols.html for the basic framework. I have done something like this to support an offline tile map cache: it does not take a lot of code. If you are careful to use relative links within your docs it could be browsable from a standard browser directly (useful for docs authoring) or through the embedded WebKit browser (indirectly).

It is, of course, easier just to ship the docs with the product.

danish.ahmed
2nd August 2012, 07:42
You are talking about your docs being a bunch-o-files in a folder on the disc: this is not the same as Qt Assistant in which all the pages are shipped in one Sqlite database.

No. I am generating all the .qch files and including them in .qhc to display the help in the QT Assistant.

I think QTWebKit and QTWebKitBridge is the way to do it.

Thanks Chris.