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. Simple application gives varying results on different Macs

Simple application gives varying results on different Macs

Scheduled Pinned Locked Moved General and Desktop
10 Posts 3 Posters 1.9k 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.
  • V Offline
    V Offline
    Vyata
    wrote on last edited by
    #1

    Hello everyone,

    I am a beginner with Qt. I made a very simple application to display an image.

    I compiled and ran the application on 4 Macs. On 2 of them the image was displayed in the window, on the other 2 no image was displayed. I have QMake version 2.01a and Qt version 4.8.6 on all the machines.

    Mac1 OS X version 10.7.5
    Mac2 OS X version 10.10.12
    Mac3 OS X version 10.6.8
    Mac4 OS X version 10.9.5

    @
    #include <QtGui>

    int main(int argc, char *argv[]) {
    QApplication a(argc, argv);
    QGraphicsScene scene;
    QGraphicsView view(&scene);

    QImage img("Test-Pattern.jpg");

    scene.addPixmap(QPixmap::fromImage(img));

    view.show();
    return a.exec();
    }
    @

    I am not sure if this problem is due to different OS versions or due to my code.
    I would really appreciate any help. Thanks!

    1 Reply Last reply
    0
    • R Offline
      R Offline
      Rondog
      wrote on last edited by
      #2

      Assuming the image was available on all four machines you might be missing the Qt image plugins on two of them. I am pretty sure you need this for jpeg files.

      If you repeat the same test using a PNG image instead of JPG and it works on all four then this is very likely your problem.

      1 Reply Last reply
      0
      • V Offline
        V Offline
        Vyata
        wrote on last edited by
        #3

        Thanks for the reply.

        No. I tested with png image files. I have the same problem.

        1 Reply Last reply
        0
        • SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on last edited by
          #4

          Hi and welcome to devnet,

          Any chance of the two failing being 10.9.5 and 10.10.12 ?

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          1 Reply Last reply
          0
          • V Offline
            V Offline
            Vyata
            wrote on last edited by
            #5

            Yes! How did you know?

            1 Reply Last reply
            0
            • SGaistS Offline
              SGaistS Offline
              SGaist
              Lifetime Qt Champion
              wrote on last edited by
              #6

              Intuition ;) And the fact that Apple changed the way it sets the working directory since 10.9 that broke some applications using QDir::currentPath() rather than QCoreApplication::applicationDirPath() to get the folder where the executable was located.

              Anyway, for your problem: "Test-Pattern.jpg" is a relative path. Where is it really located ?

              Interested in AI ? www.idiap.ch
              Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

              1 Reply Last reply
              0
              • V Offline
                V Offline
                Vyata
                wrote on last edited by
                #7

                The image file is located in the same directory as my source code.

                I just tested with full path and the the application displays images! Thank you!

                Can you suggest what I need to do make my application work for relative paths?

                1 Reply Last reply
                0
                • SGaistS Offline
                  SGaistS Offline
                  SGaist
                  Lifetime Qt Champion
                  wrote on last edited by
                  #8

                  Put the files in the right place and on OS X it's not the same folder as your application.

                  However if that file isn't too big you can also embed it in your executable

                  Interested in AI ? www.idiap.ch
                  Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                  1 Reply Last reply
                  0
                  • V Offline
                    V Offline
                    Vyata
                    wrote on last edited by
                    #9

                    I am not sure what you mean. Can you please elaborate or point me to the right documentation?

                    1 Reply Last reply
                    0
                    • SGaistS Offline
                      SGaistS Offline
                      SGaist
                      Lifetime Qt Champion
                      wrote on last edited by
                      #10

                      Sorry, I forgot the link. "Here":http://doc.qt.io/qt-5/resources.html you go, Qt's resources system

                      Interested in AI ? www.idiap.ch
                      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                      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