Results 1 to 6 of 6

Thread: qrc-files: which binary formats are supported?

  1. #1
    Join Date
    Jun 2008
    Posts
    17
    Thanks
    1
    Thanked 1 Time in 1 Post
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default qrc-files: which binary formats are supported?

    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:
    Qt Code:
    1. "...<img src=\":/images/logos/sc_mat_logo_155x40.png\" alt=\"SC-Logo\">..."
    To copy to clipboard, switch view to plain text mode 

    But when i try to do a similar thing with the pdf-file:
    Qt Code:
    1. ...<a href=\":/disclaimer/disclaimer2_wo.pdf\">...
    To copy to clipboard, switch view to plain text mode 
    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:
    Qt Code:
    1. <RCC>
    2. <qresource prefix="/" >
    3. ...
    4. <file>images/logos/sc_mat_logo_155x40.png</file>
    5. <file>disclaimer/disclaimer1_wo.pdf</file>
    6. <file>disclaimer/disclaimer2_wo.pdf</file>
    7. </qresource>
    8. </RCC>
    To copy to clipboard, switch view to plain text mode 

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,368
    Thanks
    3
    Thanked 5,018 Times in 4,794 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: qrc-files: which binary formats are supported?

    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.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  3. #3
    Join Date
    Jun 2008
    Posts
    17
    Thanks
    1
    Thanked 1 Time in 1 Post
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: qrc-files: which binary formats are supported?

    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
    Qt Code:
    1. TB->setOpenExternalLinks(false);
    To copy to clipboard, switch view to plain text mode 
    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:
    Qt Code:
    1. ...<a href=\"./some_dir_here/disclaimer1_wo.pdf\">..."
    To copy to clipboard, switch view to plain text mode 
    but not for code that gets the binary from the qrc-file, like:
    Qt Code:
    1. ...<a href=\":/disclaimer/disclaimer1_wo.pdf\">..."
    To copy to clipboard, switch view to plain text mode 

    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:
    Qt Code:
    1. ...<img src=\":/images/logos/sc_mat_logo_155x40.png\" alt=\"SC-Logo\">...
    To copy to clipboard, switch view to plain text mode 
    works fine BUT the code:
    Qt Code:
    1. ...<a href=\":/images/logos/sc_mat_logo_155x40.png\">...
    To copy to clipboard, switch view to plain text mode 
    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!

  4. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,368
    Thanks
    3
    Thanked 5,018 Times in 4,794 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: qrc-files: which binary formats are supported?

    Try "file::/images/logos/sc_mat_logo_155x40.png" as the path.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  5. #5
    Join Date
    Jun 2008
    Posts
    17
    Thanks
    1
    Thanked 1 Time in 1 Post
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: qrc-files: which binary formats are supported?

    Quote Originally Posted by wysota View Post
    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
    Qt Code:
    1. ...<img src=\":/images/logos/sc_mat_logo_155x40.png\" alt=\"SC-Logo\">...
    To copy to clipboard, switch view to plain text mode 
    works correctly with that syntax and
    Qt Code:
    1. ...<a href=\":/images/logos/sc_mat_logo_155x40.png\">
    To copy to clipboard, switch view to plain text mode 
    not...

  6. #6
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,368
    Thanks
    3
    Thanked 5,018 Times in 4,794 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: qrc-files: which binary formats are supported?

    The text browser is for.... browsing text. It's not a web viewer. If you want the latter, use QWebView.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


Similar Threads

  1. Reading Binary Files
    By archanasubodh in forum Newbie
    Replies: 1
    Last Post: 27th February 2008, 12:31
  2. How can I read Binary files with Qt
    By geo_saleh in forum Qt Programming
    Replies: 2
    Last Post: 16th August 2007, 10:37
  3. Concatenating two binary files
    By nbkhwjm in forum Newbie
    Replies: 13
    Last Post: 23rd April 2007, 03:30

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.