C++&Qt3 - Embed help files in executable

I'm building a Qt3 application in C++ and I'm using QTextBrowser and a HTML file to implement a help page.

Is there any trick anywhere in the C++ realm that would allow me to embed the HTML file and its related files in the executable, and make QTextBrowser read them directly from there?

I don't think Qt3 has any trick up the sleeve that does this. QTextBrowser expects an external path to the HTML file in its source() property.

Please don't offer solutions like "upgrade to the latest and greatest" whatever.
I want to build this in C++ and Qt3 and that will be that period.

If you don't have a real solution or idea, just don't answer.

Thank you
Qt3 docs say that QTextBrowser IS-A QTextEdit and therefore has the setText(const QString&)

If you could make the cpp include the HTML-file as string literal that the code uses to initialize a QString, you would get the text into the binary.

You, however, have multiple files, i.e. URLs within the first "HTML content".

Underneath QTextEdit there is a QMimeSourceFactory that you can customize via inheritance.
https://doc.qt.io/archives/3.3/qmimesourcefactory.html#details


I've never been there, but that does look feasible.
Thank you very much, this is a really neat trick !
Would have taken me a year to figure this out.

I did embed binary data in the executable before, but I had never tried to use it instead of external files.

I did some experimenting. I converted all files to hexdumps and included them as unsigned char arrays. For the html file, I increased the size of the binary array by one and added a NULL (0x00) at the end so I can use the array name as a string with a type conversion from unsigned char* to char*.

Then I did the MimeFactory trick and It works just fine from the QTextBrowser.

The only problem is that QTextBrowser is not really good with HTML tags, some stuff gets skipped and for instance the width attribute of table cells is not recognized.

Also, I'm not sure how to deal with links, I have some bookmarks in this document (a contents section with links) but it doesn't work when clicked. I need to do some more reading to figure out how it should work.

But yes, your idea works and is really really useful! Thanks.
Registered users can post here. Sign in or register to post.