Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Call for Presentations - Qt World Summit

    Simple application gives varying results on different Macs

    General and Desktop
    3
    10
    1532
    Loading More Posts
    • 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
      Vyata last edited by

      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 Reply Quote 0
      • R
        Rondog last edited by

        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 Reply Quote 0
        • V
          Vyata last edited by

          Thanks for the reply.

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

          1 Reply Last reply Reply Quote 0
          • SGaist
            SGaist Lifetime Qt Champion last edited by

            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 Reply Quote 0
            • V
              Vyata last edited by

              Yes! How did you know?

              1 Reply Last reply Reply Quote 0
              • SGaist
                SGaist Lifetime Qt Champion last edited by

                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 Reply Quote 0
                • V
                  Vyata last edited by

                  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 Reply Quote 0
                  • SGaist
                    SGaist Lifetime Qt Champion last edited by

                    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 Reply Quote 0
                    • V
                      Vyata last edited by

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

                      1 Reply Last reply Reply Quote 0
                      • SGaist
                        SGaist Lifetime Qt Champion last edited by

                        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 Reply Quote 0
                        • First post
                          Last post