Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. [SOLVED] How to make Qt include source files/folders in compiled file? C++
Forum Updated to NodeBB v4.3 + New Features

[SOLVED] How to make Qt include source files/folders in compiled file? C++

Scheduled Pinned Locked Moved General and Desktop
16 Posts 4 Posters 6.8k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • W Offline
    W Offline
    Woody
    wrote on last edited by
    #7

    [quote author="Rahul Das" date="1336498945"]
    [quote]
    My application can't find the files it says, although I specified them in the right way.[/quote] Are you sure!!??

    [/quote]

    Yes, added them trough Qt-creator, which seems to me the best way to do it.

    File not found. Nobody leave the room!

    1 Reply Last reply
    0
    • R Offline
      R Offline
      Rahul Das
      wrote on last edited by
      #8

      Are you using [[doc:QHelpEngine]] ??


      Declaration of (Platform) independence.

      1 Reply Last reply
      0
      • W Offline
        W Offline
        Woody
        wrote on last edited by
        #9

        Yes i do.
        Still have the problem that it doesn't show me the helpfiles. (if i use resources, using absolute path works fine though)

        File not found. Nobody leave the room!

        1 Reply Last reply
        0
        • D Offline
          D Offline
          DerManu
          wrote on last edited by
          #10

          Well we can now only help you when you show us the contents of your .qrc file and the source portion that tries to load from the resource. Did you add the qrc to the RESOURCES variable in the pro file? (QtCreator should've done that but you never know.)

          1 Reply Last reply
          0
          • W Offline
            W Offline
            Woody
            wrote on last edited by
            #11

            My qrc-file
            @<RCC>
            <qresource prefix="/help">
            <file alias="helpcollection">doc/athleticsmanager.qhc</file>
            <file>doc/athleticsmanager.qch</file>
            </qresource>
            </RCC>@

            My pro-file
            @RESOURCES +=
            help.qrc@

            Since a qhc-file is not readable I cannot show you that content, I can however show you a glimps of the qhcp-file
            @<?xml version="1.0" encoding="UTF-8"?>
            <QHelpCollectionProject version="1.0">
            <assistant>
            <title>AthleticsManager Help</title>
            <applicationIcon>images/icon.ico</applicationIcon>
            <cacheDirectory>Athleticsmanager_Dev_Help</cacheDirectory>
            <startPage>qthelp://com.athleticsmanager/doc/index.html</startPage>
            <enableDocumentationManager>false</enableDocumentationManager>
            <enableAddressBar>false</enableAddressBar>
            <enableFilterFunctionality>false</enableFilterFunctionality>
            </assistant>
            <docFiles>
            <generate>
            <file>
            <input>athleticsmanager.qhp</input>
            <output>athleticsmanager.qch</output>
            </file>
            </generate>
            <register>
            <file>athleticsmanager.qch</file>
            </register>
            </docFiles>
            </QHelpCollectionProject>@

            Calling the qhc-file:
            @void HelperDialog::initialize()
            {
            m_helpEngine = new QHelpEngine(":/help/helpcollection", this);
            m_helpEngine->setupData();
            qDebug() << "Error: " << m_helpEngine->error();
            }@

            File not found. Nobody leave the room!

            1 Reply Last reply
            0
            • D Offline
              D Offline
              DerManu
              wrote on last edited by
              #12

              put @
              qDebug() << QFile::exists(":/help/helpcollection");@
              right in front at initialize() so we rule out the possibility that the resource isn't included/referenced properly.

              1 Reply Last reply
              0
              • W Offline
                W Offline
                Woody
                wrote on last edited by
                #13

                It returns me a true, so i guess my file does exist then.
                The output of @qDebug() << "Error: " << m_helpEngine->error();@ gives me Error: "Cannot open collection file: :/help/helpcollection"

                File not found. Nobody leave the room!

                1 Reply Last reply
                0
                • W Offline
                  W Offline
                  Woody
                  wrote on last edited by
                  #14

                  In "QHelpEngine how-to":http://qt-project.org/forums/viewthread/3965 they use qrc-files as well:

                  [quote author="willypuzzle" date="1298282352"]bq. Does it work with the docs on the hard disk?
                  Did you add the file to the .qrc configuration file?
                  Are the files present in the resources? You can use QDir on file path “:/” to look at the contents.

                  It doesn't work with docs on the hard disk because I tried to add the absolute path of .qhc file (for example: QHelpEngine("/home/willy/help.qhc")) and it doesn't work.

                  I added it to .qrc configuration file and the file is present in the resources.

                  I don't understand why I have to use QDir.[/quote]

                  Ok it think I got it:

                  [quote author="Volker" date="1298486564"]...
                  Second, the more important part: You cannot use Qt resources for storing the help content. You must put it into regular files and distribute them along your application.

                  The reason for the latter is simple: The compiled help files are actually SQLite databases. Qt does not intercept the file name but hands it over directly to the SQLite functions (by calling toUtf8() on the "path"), which in turn try to open that file - and will eventually fail, of course.[/quote]

                  That's a pitty!

                  File not found. Nobody leave the room!

                  1 Reply Last reply
                  0
                  • D Offline
                    D Offline
                    DerManu
                    wrote on last edited by
                    #15

                    Hm if you desperately want to bundle everything into one file, you could of course save the help file from the resource to a temporary directory, load the help and remove the file afterwards. But only do that if you have a good reason to, normally it's even better to keep the application and such accessories (help files, translation files, multimedia) separated.

                    1 Reply Last reply
                    0
                    • W Offline
                      W Offline
                      Woody
                      wrote on last edited by
                      #16

                      Well the best that could happen to me was that I could 'store' the helpcollectionfile (qhc) in a resourcefile (qrc). So it can easily be distributed. Cause this application is going to be used by hundreds, maybe thousands of users. And then it would be much easier to get it in just one executable.

                      My colleague is coming back next week, i'll ask him if he has a decent solution. But thanks for the help anyway :) Great forums here

                      File not found. Nobody leave the room!

                      1 Reply Last reply
                      0

                      • Login

                      • Login or register to search.
                      • First post
                        Last post
                      0
                      • Categories
                      • Recent
                      • Tags
                      • Popular
                      • Users
                      • Groups
                      • Search
                      • Get Qt Extensions
                      • Unsolved