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] using the prefix in a resource file

[SOLVED] using the prefix in a resource file

Scheduled Pinned Locked Moved General and Desktop
14 Posts 5 Posters 8.3k Views
  • 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.
  • F Offline
    F Offline
    Franzk
    wrote on last edited by
    #2

    You don't. The files you use are encoded into a cpp file resulting from the rcc tool. They are then compiled into your program. The prefix is used for making (logical) separations between groups of images/whatever.

    "Horse sense is the thing a horse has which keeps it from betting on people." -- W.C. Fields

    http://www.catb.org/~esr/faqs/smart-questions.html

    1 Reply Last reply
    0
    • X Offline
      X Offline
      xeroblast
      wrote on last edited by
      #3

      so i have to use :

      @
      QUrl url("path/to/file");
      QDir::homePath() + url.toLocalFile();
      @

      1 Reply Last reply
      0
      • G Offline
        G Offline
        giesbert
        wrote on last edited by
        #4

        What exactly do you want to achieve?

        Access to resources is done this way:

        QFile f (":/myPrefix/mySubprefeix/name");
        the ":" in the beginning tells qt to use the resources.

        Nokia Certified Qt Specialist.
        Programming Is Like Sex: One mistake and you have to support it for the rest of your life. (Michael Sinz)

        1 Reply Last reply
        0
        • F Offline
          F Offline
          Franzk
          wrote on last edited by
          #5

          If you want to load an image from a certain location, use QDir::homePath(), QUrl or whatever is required (QFileDialog, QDesktopServices). If you need an image in your resource file, use the resource editor to add it and let Qt handle it. You don't need access to the home dir then.

          "Horse sense is the thing a horse has which keeps it from betting on people." -- W.C. Fields

          http://www.catb.org/~esr/faqs/smart-questions.html

          1 Reply Last reply
          0
          • X Offline
            X Offline
            xeroblast
            wrote on last edited by
            #6

            im putting configuration files in the home directory.
            the QFile cant read the file unless i put the file in the current folder.

            unix: /home/username/.myapp/files.ext
            windows: c:\Documents and Settings\username\Application Data\myapp\files.ext

            1 Reply Last reply
            0
            • F Offline
              F Offline
              Franzk
              wrote on last edited by
              #7

              On both platforms?
              Why not use QSettings?

              "Horse sense is the thing a horse has which keeps it from betting on people." -- W.C. Fields

              http://www.catb.org/~esr/faqs/smart-questions.html

              1 Reply Last reply
              0
              • A Offline
                A Offline
                andre
                wrote on last edited by
                #8

                In that case, you should look into the QDesktopServices class. It will supply you with a cross platform way to query for locations on disk like this. In your case, you are probably looking for QDesktopServices::DataLocation.

                Note that inside your Qt program, you should use forward slashes for all file paths, even on Windows. Only for paths you display to the user, you can use QDir::toNativeSeparators to get the native format.

                1 Reply Last reply
                0
                • X Offline
                  X Offline
                  xeroblast
                  wrote on last edited by
                  #9

                  Franzk: i cant use QSettings cause i need to save the configurations to a file so i could load it again using the QFile then use QSettings.

                  Andre: i think ill try QDesktopServices::DataLocation. it seems that this directory is where my configurations files to be stored.

                  1 Reply Last reply
                  0
                  • F Offline
                    F Offline
                    Franzk
                    wrote on last edited by
                    #10

                    [quote author="xeroblast" date="1299583686"]Franzk: i cant use QSettings cause i need to save the configurations to a file so i could load it again using the QFile then use QSettings.[/quote]

                    QSettings can do ini files. You just have to explicitly tell it to do that on windows. On linux the settings are stored in ~/.config/.

                    "Horse sense is the thing a horse has which keeps it from betting on people." -- W.C. Fields

                    http://www.catb.org/~esr/faqs/smart-questions.html

                    1 Reply Last reply
                    0
                    • X Offline
                      X Offline
                      xeroblast
                      wrote on last edited by
                      #11

                      [quote author="Franzk" date="1299585456"]QSettings can do ini files. You just have to explicitly tell it to do that on windows. On linux the settings are stored in ~/.config/.[/quote]

                      ok. i think this is what i want. i just didnt know where the ini files located. i thought QSettings didnt saved it.

                      so in windows, where is the ini files located?

                      1 Reply Last reply
                      0
                      • F Offline
                        F Offline
                        Franzk
                        wrote on last edited by
                        #12

                        It saves them where you tell it to save them. By default it will go for registry, but there's the option of setting the format and file: http://doc.trolltech.com/latest/qsettings.html#QSettings-4

                        "Horse sense is the thing a horse has which keeps it from betting on people." -- W.C. Fields

                        http://www.catb.org/~esr/faqs/smart-questions.html

                        1 Reply Last reply
                        0
                        • X Offline
                          X Offline
                          xeroblast
                          wrote on last edited by
                          #13

                          thanks for the info...

                          1 Reply Last reply
                          0
                          • S Offline
                            S Offline
                            shadow.seeker
                            wrote on last edited by
                            #14

                            Resolved mine also. thanks again.
                            Can there be a small an example put in the list also. Would help lot as most of us spend loads of time searching it.

                            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