Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Installation and Deployment
  4. Compiled application don't find QML elements
QtWS25 Last Chance

Compiled application don't find QML elements

Scheduled Pinned Locked Moved Installation and Deployment
17 Posts 4 Posters 17.8k 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.
  • AlicemirrorA Offline
    AlicemirrorA Offline
    Alicemirror
    wrote on last edited by
    #5

    Thank you, but this was not the problem. I just tested now.

    Then I seta qrc file with the images, qml and html paths in three different sections. I am trying to see if this method works.

    Enrico Miglino (aka Alicemirror)
    Balearic Dynamics
    Islas Baleares, Ibiza (Spain)
    www.balearicdynamics.com

    1 Reply Last reply
    0
    • AlicemirrorA Offline
      AlicemirrorA Offline
      Alicemirror
      wrote on last edited by
      #6

      Well, I have done some tests and the conclusion is that something is wrong or something is lost or something need to be changed.

      The behavior described above is strange, and the tests and changes done are very simple and obvious: the paths a right and correct, as the documentation explain.

      now following your suggesions - Andre - I setup a wrc file with all the resources listed. It is ver simple, withouth any other than the list of the qml files and images. The paths are impossible to be wrong because I used the IDE where file should be searched with a dialog box.
      Then, I changed the main.cc only in two lines: Q_INIT_RESOURCE call to initialize the resources in the resources.qrc file and in the call to qml main program.

      @#include <QtGui/QApplication>
      #include <QCoreApplication>
      #include "qmlapplicationviewer.h"

      int main(int argc, char *argv[])
      {
      Q_INIT_RESOURCE(resources);
      QApplication app(argc, argv);

      app.setApplicationName("RC Hobby Stream by ");
      app.setApplicationVersion("1.0rc LGPL 3.0 lic. by Tech Consulting, enrico.miglino@ovi.com");
      app.setOrganizationName("Maplegate Media Group");
      
      QCoreApplication::addLibraryPath("plugins");
      // Creation of the viewer instance
      QmlApplicationViewer viewer;
      viewer.setOrientation(QmlApplicationViewer::ScreenOrientationAuto);
      
      // Modifications to remove window attributes
      viewer.setStyleSheet("background:transparent;");
      viewer.setAttribute(Qt::WA_TranslucentBackground);
      viewer.setWindowFlags(Qt::FramelessWindowHint);
      
      // set the qml starting program
      viewer.setMainQmlFile&#40;QLatin1String(":/main.qml"&#41;);
      viewer.showExpanded();
      
      return app.exec();
      

      }@

      Well, recompiled in debug without any warning or error. When the program starts the object viewer really contains the string name but starting I receive the error that the main.qml file is not found.

      The very strange thing (or what I don't expect) is that the not found file is the following line:

      @file:///E:/QTDevel/RCHobbyStream-build-desktop/:/main.qml: File not found@

      This seems to me something of bad path, just as Qt resource system is not working correctly.
      Thus, to complete all the possible tests I thought, I pushed the git repo from the windows machine to the public repository (hosted at http://projects.forum.nokia.com/rchobbystream) then taken the same project in the Mac environment. Started the Qt Creator and opened the project, leaving all unchanged. The result is about the same, with the project locally stored in the path ~/QTDevel/rchobbystream:

      @file:///Users/enrico/QTDevel/RCHobbyStream-build-desktop/RCHobbyStream.app/Contents/MacOS/:/main.qml: File not found @

      I have no more idea. Some suggestions ?

      Enrico Miglino (aka Alicemirror)
      Balearic Dynamics
      Islas Baleares, Ibiza (Spain)
      www.balearicdynamics.com

      1 Reply Last reply
      0
      • AlicemirrorA Offline
        AlicemirrorA Offline
        Alicemirror
        wrote on last edited by
        #7

        Other tests done.

        Using Qt resource system nothing works, also under the Qt Creator IDE. The error is always the same, main.qml could not be find.
        Then, reusing the relative paths with the sources under the 'qml' folder the program work and compile correctly but if I run it standalone does not find the file the is surely in the folder where the program expects.

        Enrico Miglino (aka Alicemirror)
        Balearic Dynamics
        Islas Baleares, Ibiza (Spain)
        www.balearicdynamics.com

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

          You are doing something wrong, as I use this setup in a project, and I know for a fact that works :-)

          1 Reply Last reply
          0
          • AlicemirrorA Offline
            AlicemirrorA Offline
            Alicemirror
            wrote on last edited by
            #9

            Andre I am sure that I am doing something wrong. And probably it is a so stupid thing that I can't imagine.

            All the work was done on the drive E: and now I am moving the project on the drive C: (standard windows), the same where the SDK is installed.

            Its possible that I missed something ?

            Enrico Miglino (aka Alicemirror)
            Balearic Dynamics
            Islas Baleares, Ibiza (Spain)
            www.balearicdynamics.com

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

              Are you sure you are not using an absolute path somewhere?

              1 Reply Last reply
              0
              • AlicemirrorA Offline
                AlicemirrorA Offline
                Alicemirror
                wrote on last edited by
                #11

                Yes, Andre, absolutely sure. But at this moment it doesn't matter, because the first step is to see that program running in the compiled version at leat with main working. In previous versions, there was not plugins, so something wasn't working like the jpeg files but it starts and show a blank window of the wrong size. Not only can't be there an absolute path because in the Qt IDE everything works also when I move from one drive to another.

                There are two things that I am not sure what means:

                1. in the project I set these lines on top, because I found this in all the examples and other projects but is possible that I have not understood clearly what does it means.

                @# Add more folders to ship with the application, here
                folder_01.source = qml
                folder_01.target = qml
                DEPLOYMENTFOLDERS = folder_01@

                1. When I compile, with the settings explained above, Qt create the folder Rc_Hobby_Stream_build_desktop that contains the following subfolders:

                qml/qml/main.qml
                qml/qml/elements/qml files
                release/the compiled exe
                debug/the compiled exe

                The strange thing is that I don'set in the project (and in the main.cpp program) this double qml/qml folder tree, there is only one folder.
                When I run the program from the Qt IDE, I receive the error main.qml not found, because the program search it in the right directory: Rc_Hobby_Stream_build_desktop/qml/main.qml

                Well, I remove the redundant /qml/ folder and all works fine. Thisi last thing is what that suggest to me that something is wrong.

                Enrico Miglino (aka Alicemirror)
                Balearic Dynamics
                Islas Baleares, Ibiza (Spain)
                www.balearicdynamics.com

                1 Reply Last reply
                0
                • AlicemirrorA Offline
                  AlicemirrorA Offline
                  Alicemirror
                  wrote on last edited by
                  #12

                  Finally I found the problem!!!

                  Last night after another set of annoying tests and controls, I focused where is exactly the problem. Unfortunately this doesn't mean that it is solved, but now I can investigate on the error (??? if it is) seeing in the right direction.

                  Note: to develop I am using the Qt SDK 1.1 beta, but as I explain further it doesn't matter.

                  The fact that QML components are working in the IDE while don't work running the program stand-alone suggested to start a line of investigation on main.cpp calling main.qml, and Andre got a lot of helpful hints to check the correct path, see if the QML components were in the right place, if all the dll and plugins were copied etc. Then I have also investigated on the main.cpp code structure.

                  During my tests I experienced the same problem on linux Ubuntu 10.4LT, Mac OSX 10.5 Snow Leopard, Windows 7 Perfection SP1, Windows XP professional SP2...

                  At this point a thing was clear: the cpp components of the application was correct. So where is the problem?

                  1. I created a fresh virtual Windows 7 machine and installed the Qt Creator and Qt SDK 1.0, to have the same development environment as described by Andre some posts above in this thread. The result was the same, so I excluded that in my development configuration with the new SDK 1.1 beta something was wrong.

                  2. I left unchanged the C sources and structure and changing only the QML sources, using an old version, the 1.0.3 beta of the same application. Astonished last night at 3 A.M. I saw that all was working!!!

                  At the actual date I am debugging the QML sources, but the thing very strange for me concerns the real question, at this point:

                  What can be that QML code works only when the program run inside the Qt-Quick IDE, while it shows a blank screen when is run stand-alone (in a separate folder, with the dll and plugins?)

                  If someone has any idea is welcome :)

                  Enrico Miglino (aka Alicemirror)
                  Balearic Dynamics
                  Islas Baleares, Ibiza (Spain)
                  www.balearicdynamics.com

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

                    Are you sure you also distribute all the needed libraries that you reference (indirectly) from your QML, and that may be in the path when you run from Qt Creator? I am thinking about things like the QtMobility related libraries...

                    1 Reply Last reply
                    0
                    • AlicemirrorA Offline
                      AlicemirrorA Offline
                      Alicemirror
                      wrote on last edited by
                      #14

                      Hi Andre, you think good :)

                      Plugins was correctly delivered, and all the libraries evidentiated by dependecy walker, but it was not sufficient because there was a couple of dll that needed to be added.

                      When I checked (this will be in next post) and verified that also the qml was working, I tried to do the oppposite as adding the dll. Added all and removed what I was reasonably sure that are sensless.
                      And now it works.

                      Remain only the qml debugger that I setup correctly, but when the debugger starts, tell me that the debugger can't connect with the server. This can depend by some piece of code I should add in the source? I only setup all that the guide ask for, but the code remain unchanged.

                      Enrico Miglino (aka Alicemirror)
                      Balearic Dynamics
                      Islas Baleares, Ibiza (Spain)
                      www.balearicdynamics.com

                      1 Reply Last reply
                      0
                      • AlicemirrorA Offline
                        AlicemirrorA Offline
                        Alicemirror
                        wrote on last edited by
                        #15

                        Situation change and update

                        Atthe actual date, this strange problem has not yet finished to astonish...

                        The installation directory is working with all the needed dll. While the aplication is in the same computer where is also installed Qt SDK. Then, I tried to move in a "empty" windows machine and the application show the same simpthoms explained before.

                        So I do the following test: all the dll under .../desktop/mingw/bin was copied in the application directory, while all the plugin dll was copied in subdirectories under the /plugin application directory.

                        In this condition, the application directory contains all needed and not needed components (it is about 65 Mb). When I copy the application directory in a windows machine where the Qt sdk is not installed, the application starts with a blank screen.

                        No more ideas to test :)

                        Enrico Miglino (aka Alicemirror)
                        Balearic Dynamics
                        Islas Baleares, Ibiza (Spain)
                        www.balearicdynamics.com

                        1 Reply Last reply
                        0
                        • A Offline
                          A Offline
                          Adversus
                          wrote on last edited by
                          #16

                          Old thread but thought I'd post my solution: had a bit of the same problem. I was able to sort out all needed dependencies by:

                          • Using resources for qml files
                          • Using dependencywalker to find missing dlls in the main exe file, copying them into the exe folder
                          • Starting from a dummy main.qml that paints a red rectangle. One by one I added the qml imports in main.qml, compiled and then ran the standalone app. If it did not run there was a problem with the imported plugin -> fix it: add the plugin in a QtQuick folder in the directory of the exe + use dependencywalker to check if all the required dlls are present

                          Its a bit tedious but with this step-wise approach you're sure to sort it out.

                          edit: never mind, ended up following the instructions "here":http://qt-project.org/wiki/Deploy_an_Application_on_Windows

                          1 Reply Last reply
                          0
                          • AlicemirrorA Alicemirror

                            Hi to all.

                            I am sadly experiencing a very strange behavior in Qt-Quick when I try to deploy a windows desktop application. I apologize if this post is too long, but I will be sure to descibe exactly what I am doing (including annoying and some obvious operations). I am sure that one or more steps of my proceeding are wrong, but I can't identify them.

                            1. The program is finished and works correctly, when I compile under Qt IDE and run the release.

                            2. Settings for project folders are the following:

                            @QTDevel
                            +--MyAppFolderName
                            +--qml
                            | +--MyAppFolderName
                            | +--main.qml
                            | +--elements
                            | +[All Qml Sources.qml]
                            +--main.cpp@

                            Then I compile the application for the desktop, with shadowbuilder option active. At this point I obtain a build dir for the desktop as follows:

                            @QTDevel
                            +--MyAppFolderName-build-desktop
                            +--qml
                            | +--qml
                            | +--MyAppFolderName
                            | +--main.qml
                            | +--elements
                            | +--[All Qml Sources.qml]
                            | +--[All Other Files (images etc.)]
                            +--MyAppProgram.exe@

                            With this folder tree (created by Qt IDE) the application report the error not found for the qml source main.qml, so I need to remove the second 'qml' folder. Then after this manual operation the application runs under the Qt IDE.

                            At this point, to see the application working out of the Qt IDE I need libraries and plugins. Thus with DependencyViewer I search what are the missing DLL and add the corresponding plugins, so the build-desktop folder became as follows:

                            @QTDevel
                            +--MyAppFolderName-build-desktop
                            +--qml
                            | +--MyAppFolderName
                            | +--main.qml
                            | +--elements
                            | +--[All Qml Sources.qml]
                            | +--[All Other Files (images etc.)]
                            +--MyAppProgram.exe
                            +--plugins
                            | +--[A different folder for every plugin]
                            +--[All the DLL needed to run the application]
                            @

                            Note: In the MyAppProgram.pro project file I set the following folder to be included in the deployment path:

                            @folder_01.source = qml
                            folder_01.target = qml
                            DEPLOYMENTFOLDERS = folder_01@

                            while in the main.cpp source I setup the plugin path:

                            @int main(int argc, char *argv[])
                            {
                            QApplication app(argc, argv);

                            QCoreApplication::addLibraryPath("plugins");
                            // Creation of the viewer instance
                            QmlApplicationViewer viewer;
                            viewer.setOrientation(QmlApplicationViewer::ScreenOrientationAuto);
                            
                            // set the qml starting program
                            viewer.setMainQmlFile&#40;QLatin1String("qml/MyAppProgram/main.qml"&#41;&#41;;
                            viewer.showExpanded(&#41;;
                            
                            return app.exec(&#41;;
                            

                            }@

                            When I launch MyAppProgram.exe the application starts, but seems that no Qml file or object is loaded. I suppose that this is the build directory, while the final deploy directory is different. How can I setup correctly the path to have the application working correctly?

                            Thank to all for any suggestion.

                            M Offline
                            M Offline
                            Manoj_Sahu
                            wrote on last edited by
                            #17

                            @Alicemirror
                            Though too late reply yet worth posting.
                            If qrc is not used then Absolute path of qml file
                            like
                            "/home/manoj/QT/qmlFileDemo/main.qml" can solve the problem.

                            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