PDA

View Full Version : qrc-files: which binary formats are supported?



freeman_w
3rd September 2009, 12:15
Hallo!

I would like to store 2 pdf-files in a qrc-file... In the Assistant you get to read:
"The Qt resource system is a platform-independent mechanism for storing binary files in the application's executable.". And there is nothing else said about supported binary formats!
So i guess that you can store ANYTHING in a qrc-file
But when i try to do that, it seems that it doesn't work for the pdf-files!

My goal is to launch the pdf from a html-link, within a TextBrowser (TB)!
When i try to show an image within the TB that is also stored in the same resource file, it works fine!

I use the following code to show the image (which works fine) within the TB:


"...<img src=\":/images/logos/sc_mat_logo_155x40.png\" alt=\"SC-Logo\">..."


But when i try to do a similar thing with the pdf-file:


...<a href=\":/disclaimer/disclaimer2_wo.pdf\">...

i get an error message like:


File or Dir file:///disclaimer/disclaimer2_wo.pdf does not exist.


If i put the pdf-files in another dir and try to load them out of the resource-file, it also works fine!
So why the hell does it not work from within the qrc-file???
Why does it work for all images but not for the pdfs??? Are only images supported???

I use QT 4.4.3 under OpenSUSE 10.2 and i don't need an answer saying "try to upgrade your QT" or stuff like that...
I HAVE TO work with that system. I just want to understand why it is not working the way is SHOULD WORK...
Thankfull for any other sort of help/hint....

My resource file looks like:


<RCC>
<qresource prefix="/" >
...
<file>images/logos/sc_mat_logo_155x40.png</file>
<file>disclaimer/disclaimer1_wo.pdf</file>
<file>disclaimer/disclaimer2_wo.pdf</file>
</qresource>
</RCC>

wysota
3rd September 2009, 13:48
QTextBrowser doesn't know how to show pdf files, so it doesn't really matter if the file is embedded into the binary or not. If you had an image handler for pdf that could work on raw data passed to it and not only on file names, it would have interpreted that pdf from qrc correctly.

freeman_w
3rd September 2009, 14:34
Thx for answering...
Have still some problems with that answer!
Qt doesn't have a prob with opening the pdf-file within the TB!
When i set

TB->setOpenExternalLinks(false);
then it just throws the binary content of the pdf-file in the TB, just as if you would try to open a binary file within a Browser like IE or Firefox.
But it just works for the pdf-files that are stored in a normal dir on the filesystem.
So it works for code like:

...<a href=\"./some_dir_here/disclaimer1_wo.pdf\">..."
but not for code that gets the binary from the qrc-file, like:

...<a href=\":/disclaimer/disclaimer1_wo.pdf\">..."

The other interesting thing that i noticed now is that, not even the image-files can be shown correctly when you try to work with them as LINKS.
So the code:

...<img src=\":/images/logos/sc_mat_logo_155x40.png\" alt=\"SC-Logo\">...
works fine BUT the code:

...<a href=\":/images/logos/sc_mat_logo_155x40.png\">...

DOESN'T...

Is it an interpretation problem from "<a href=..." within the TB?
Every problem from above appears with both states of TB->setOpenExternalLinks().
So that property shouldn't be the key to solving that!

wysota
3rd September 2009, 14:46
Try "file::/images/logos/sc_mat_logo_155x40.png" as the path.

freeman_w
3rd September 2009, 15:35
Try "file::/images/logos/sc_mat_logo_155x40.png" as the path.

NICE one! =) At least, it finds the image-file now...
But it doesn't open it as an image... It justs throws the binary content in the TB-widget.
The location problem/question is solved/answered this way.
But if you use the "file::" in the location, then you can't open that specific link with an external app.
So I can only try to open it IN the TB... But TBs cannot show pdfs.
TB->setOpenExternalLinks(true) doesn't include those kind of links :/

I still don't get why the

...<img src=\":/images/logos/sc_mat_logo_155x40.png\" alt=\"SC-Logo\">...
works correctly with that syntax and

...<a href=\":/images/logos/sc_mat_logo_155x40.png\">
not...

wysota
3rd September 2009, 16:31
The text browser is for.... browsing text. It's not a web viewer. If you want the latter, use QWebView.