Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Qt Creator and other tools
  4. [SOLVED] Resources compilation from Qt Creator
Forum Updated to NodeBB v4.3 + New Features

[SOLVED] Resources compilation from Qt Creator

Scheduled Pinned Locked Moved Qt Creator and other tools
6 Posts 3 Posters 6.9k 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.
  • F Offline
    F Offline
    Fomand
    wrote on last edited by
    #1

    Is there any way to get qrc_...cpp from Qt Creator or the only way is to go to RCC directly?

    And one more strange thing - if I start Qt Designer alone it shows the tab "Resources" next to "Actions". If I edit ...ui file from Qt Creator - there is no "Resources" tab. How it is so?

    And there is no visible icons in ToolBar when application is running.
    There are visible icons in Qt Designer.

    Executed qmake from the menu of Qt Creator - no changes.

    qmake-qt4 /home/user/Test.pro -r -spec linux-g++-64 CONFIG+=debug

    Ubuntu, Qt 4.7.4, Qt Creator 2.3.0

    Thanks!

    @
    #-------------------------------------------------

    Project created by QtCreator 2011-09-04T09:05:32

    #-------------------------------------------------

    QT += core gui

    TARGET = Fom_Data_Studio
    TEMPLATE = app

    SOURCES += main.cpp
    mainwindow.cpp

    HEADERS += mainwindow.h

    FORMS += mainwindow.ui

    RESOURCES +=
    resources.qrc
    @


    resources.qrc:

    @
    <RCC>
    <qresource prefix="/new/prefix1"> <------------------------------- /new/prefix1 looks strange for me
    <file>images/Actions-dialog-close-icon.png</file>
    <file>images/Actions-document-open-icon.png</file>
    <file>images/Actions-list-add-icon.png</file>
    <file>images/Actions-svn-commit-icon.png</file>
    <file>images/Actions-svn-update-icon.png</file>
    <file>images/Actions-system-shutdown-icon.png</file>
    <file>images/Actions-window-close-icon.png</file>
    <file>images/cabinet-close.png</file>
    <file>images/cabinet-new.png</file>
    <file>images/cabinet-open.png</file>
    <file>images/Places-bookmarks-icon.png</file>
    <file>images/Places-folder-downloads-icon.png</file>
    <file>images/Places-folder-favorites-icon.png</file>
    <file>images/Status-user-online-icon.png</file>
    </qresource>
    </RCC>
    @

    [EDIT: code formatting, please wrap in @-tags, Volker]

    1 Reply Last reply
    0
    • L Offline
      L Offline
      lgeyer
      wrote on last edited by
      #2

      I'm not quite sure about your problem but /new/prefix1 is the default prefix generated by Qt Creator if you do not enter a value by yourself. It can be freely changed or removed.

      The resource file is a simple XML file which can be edited out of Qt Creator using any text editor.

      1 Reply Last reply
      0
      • F Offline
        F Offline
        Fomand
        wrote on last edited by
        #3

        Thx for reply.

        1. My resource file in the post and it is obvious that it is XML. It must provide images for buttons, but it does not - this is THE ISSUE.
        2. Prefix - can it prevent from including *.png in application? Should I change / remove it?
        3. For me PREFIX should contain "images/" and file names should be without it. But I tried to do so - it does not work. Any ideas would be appreciated.
        1 Reply Last reply
        0
        • G Offline
          G Offline
          goetz
          wrote on last edited by
          #4

          The file tags contain the paths relative to the directory where the qrc file lives. You must not remove the "images" part, as qrc cannot find the files then - we talk about physical files here.

          The prefix attribute of the qresource tag puts that files into a virtual subdirectory in the qrc file namespace ("qrc:/"). It is prepended to the paths of the file tags. You can remove the prefix (or set it to "/").

          At the moment, to access your images, would have to write

          @
          QImage cabinetNew(":/new/prefix1/images/cabinet-new.png");
          @

          See "The Qt Resource System":http://developer.qt.nokia.com/doc/qt-4.7/resources.html in the docs for an detailed explanation of the features and file format.

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

          1 Reply Last reply
          0
          • L Offline
            L Offline
            lgeyer
            wrote on last edited by
            #5

            Resources are beeing accessed using the :/ prefix. The prefix specified in the qresource tag is optional. Only resources specifically listed in the RCC file are added - there are no wildcards like * or automated includes.
            @
            // <qresource prefix="/new/prefix1">
            QIcon openIcon(":/new/prefix1/images/Actions-document-open-icon.png");

            // <qresource prefix="/">
            QIcon openIcon(":/images/Actions-document-open-icon.png");

            // <qresource>
            QIcon openIcon(":/images/Actions-document-open-icon.png");
            @

            1 Reply Last reply
            0
            • F Offline
              F Offline
              Fomand
              wrote on last edited by
              #6

              Solved:

              1. I created RESOURCES file in Qt Creator and included icons there.
              2. In Qt Designer I selected an icon from RESOURCES (not from file).

              It all works now.

              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