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. How to located image files for MAC?
Forum Updated to NodeBB v4.3 + New Features

How to located image files for MAC?

Scheduled Pinned Locked Moved General and Desktop
5 Posts 2 Posters 3.2k 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.
  • C Offline
    C Offline
    curedream
    wrote on last edited by
    #1

    When win32...

    appfolder/
    appfolder/image/1.png
    2.png
    appfolder/app.exe
    icon.addFile("image/1.png"~~~~~~~;

    Load image is Ok.

    When MAC OS

    app.app/
    app.app/Contents/
    app.app/Contents/MacOS/app

    image/ < load image success. but i want this not...

    app.app/Contents/MacOS/image/1.png <- don't load image
    app.app/Resources/image/1.png <- don't load image

    when i coding >>icon.addFile("image/1.png"~~~~~~~;
    app.app/Resources/image/1.png <-- want load image..

    Because When i do design form, I use the QT Designer.
    Auto Create ui_mainwindow.h
    this line icon.addFile("image/1.png"~~~~~~~; ...

    1 Reply Last reply
    0
    • G Offline
      G Offline
      goetz
      wrote on last edited by
      #2

      The correct path is

      app.app/Contents/Resources ... maybe with subdirs, that's up to you.

      To construct a path use this snippet:

      @
      #ifdef Q_OS_MACX
      QString imageDir = QCoreApplication::applicationDirPath() + "/../Resources";
      #else
      QString imageDir = QCoreApplication::applicationDirPath();
      #endif

      icon.addFile(imageDir + "/1.png");
      @

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

      1 Reply Last reply
      0
      • C Offline
        C Offline
        curedream
        wrote on last edited by
        #3

        thanks.

        But this code automatic created. -> icon.addFile("1.png");

        Because I made that desing form. That code auto created..

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

          In that case you should remove the images from the designer form and set the icons programmatically in your C++ class.

          Another solution would be to put the icons into a "Qt Resource file":/doc/qt-4.8/resources.html. You can use those in "Designer:"/doc/qt-4.8/designer-resources.html as well.

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

          1 Reply Last reply
          0
          • C Offline
            C Offline
            curedream
            wrote on last edited by
            #5

            Okay. Thanks.

            Have a good week.

            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