Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. QML to .exe
Forum Updated to NodeBB v4.3 + New Features

QML to .exe

Scheduled Pinned Locked Moved QML and Qt Quick
27 Posts 7 Posters 18.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.
  • B Offline
    B Offline
    blex
    wrote on last edited by
    #2

    Is Qmlviewer the right tool?


    Oleksiy Balabay

    1 Reply Last reply
    0
    • D Offline
      D Offline
      DenisKormalev
      wrote on last edited by
      #3

      You can write small wrapper (I think Creator already can do it automatically, but not sure) for showing qml.

      1 Reply Last reply
      0
      • K Offline
        K Offline
        kyleplattner
        wrote on last edited by
        #4

        If you could provide me with some more details of how exactly to get from the .qml files to a usable .exe, that would be helpful. Thanks,

        Kyle

        1 Reply Last reply
        0
        • D Offline
          D Offline
          DenisKormalev
          wrote on last edited by
          #5

          something like (not tested, just coded here in reply form)
          @
          int main (int argc, char **argv)
          {
          QApplication app(argc,argv);
          QDeclarativeView view("/path/to/your/Example.qml");
          view.setResizeMode(QDeclarativeView::SizeRootObjectToView);
          view.resize(500,500); //this and prev lines are needed only if you don't have sizes in root element of your qml
          view.show();
          return app.exec();
          }
          @

          1 Reply Last reply
          0
          • K Offline
            K Offline
            kyleplattner
            wrote on last edited by
            #6

            Can I compile this in any compiler?

            1 Reply Last reply
            0
            • D Offline
              D Offline
              DenisKormalev
              wrote on last edited by
              #7

              I don't think that compiler can be problem here. Just make sure you have all needed in your env variables.

              1 Reply Last reply
              0
              • K Offline
                K Offline
                kyleplattner
                wrote on last edited by
                #8

                Where can I download all the environment variables? While I tried to compile, I got a QApplication undeclared error.

                1 Reply Last reply
                0
                • D Offline
                  D Offline
                  DenisKormalev
                  wrote on last edited by
                  #9

                  you have to include them. Sorry I forgot them.

                  @
                  #include <QApplication>
                  #include <QDeclarativeView>
                  @

                  Also don't forget to add gui and declarative to QT var in your .pro file.

                  1 Reply Last reply
                  0
                  • K Offline
                    K Offline
                    kyleplattner
                    wrote on last edited by
                    #10

                    Please excuse my ignorance but you will have to explain the last sentence you wrote. I do not have a .pro file, do I need one?

                    1 Reply Last reply
                    0
                    • D Offline
                      D Offline
                      DenisKormalev
                      wrote on last edited by
                      #11

                      Yes, you need a .pro file.

                      1 Reply Last reply
                      0
                      • K Offline
                        K Offline
                        kyleplattner
                        wrote on last edited by
                        #12

                        Again, forgive my beginner questions but how do I create one? What is it?

                        1 Reply Last reply
                        0
                        • D Offline
                          D Offline
                          DenisKormalev
                          wrote on last edited by
                          #13

                          Save code I wrote you before as main.cpp and run in folder with it
                          @
                          qmake -project
                          @

                          It will create a .pro file. Open it and find QT var. I think it will contain only
                          @
                          QT += core gui
                          @
                          make it
                          @
                          QT += core gui declarative
                          @

                          After it run qmake in this folder with name of .pro file as argument. And after it run make (or nmake, if you are using msvc compiler).

                          1 Reply Last reply
                          0
                          • K Offline
                            K Offline
                            kyleplattner
                            wrote on last edited by
                            #14

                            I did every step up until the make command which returned:
                            make: *** No targets specified and no makefile found. Stop.

                            1 Reply Last reply
                            0
                            • D Offline
                              D Offline
                              DenisKormalev
                              wrote on last edited by
                              #15

                              Is there Makefile file created after ?
                              @
                              qmake yourproject.pro
                              @

                              1 Reply Last reply
                              0
                              • K Offline
                                K Offline
                                kyleplattner
                                wrote on last edited by
                                #16

                                the command executes without an error, but I don't see a makefile

                                1 Reply Last reply
                                0
                                • D Offline
                                  D Offline
                                  DenisKormalev
                                  wrote on last edited by
                                  #17

                                  What files fo you have in your folder after running this command?

                                  1 Reply Last reply
                                  0
                                  • K Offline
                                    K Offline
                                    kyleplattner
                                    wrote on last edited by
                                    #18

                                    1.qml Keyboard.qml
                                    10.qml Map.qml
                                    11.qml MenuTabText.qml
                                    12.qml MenuText.qml
                                    13.qml MenuTitle.qml
                                    2.qml PanMap.qml
                                    25.qml QML.pro
                                    3.qml QMLFinal.qml
                                    4.qml QMLFinal.qmlproject
                                    5.qml QMLFinal.qmlproject.user
                                    6.qml RandNumGenerator.qml
                                    7.qml SetupBars.qml
                                    8.qml SetupBlack.qml
                                    9.qml TabMenu.qml
                                    Back.qml WidgetLarge.qml
                                    CheckBox.qml WidgetSmall.qml
                                    Dashboard.qml build
                                    DropDown.qml keyboard.png
                                    Front.qml main.cpp
                                    GPSWidget.qml main.h
                                    HomeText.qml map.png
                                    Images
                                    Info.plist

                                    1 Reply Last reply
                                    0
                                    • D Offline
                                      D Offline
                                      DenisKormalev
                                      wrote on last edited by
                                      #19

                                      so you run in this folder
                                      @
                                      qmake QML.pro
                                      @
                                      and nothing new appears?
                                      If yes then sorry, but I can't help with problem. Maybe some one more familiar with windows can.

                                      1 Reply Last reply
                                      0
                                      • D Offline
                                        D Offline
                                        DenisKormalev
                                        wrote on last edited by
                                        #20

                                        Try to open this .pro in QtCreator and build it there. I think it will help you.

                                        1 Reply Last reply
                                        0
                                        • T Offline
                                          T Offline
                                          tobias.hunger
                                          wrote on last edited by
                                          #21

                                          This is mostly interesting to demo something on a mobile device and not so much for a desktop application.... but try this to get a .pro file that can get used to build an executable able to display your QML:

                                          • Update creator to 2.1 beta. We did improve the templates for QML based projects there a lot.
                                          • Set up a new project: File->New File or Project.
                                          • Select "Qt Quick Project" and then "Qt Quick Application". A wizard opens when you click on OK.
                                          • Provide a new project name and a directory to store the project (in a subfolder named like the project name you are giving!) in. Next.
                                          • Select a Qt version (4.7.1 is preferred nowadays) in Desktop. Add mobile devices if required (and you have the support installed). Next.
                                          • You can ignore the next page of the wizard, it is only relevant for mobile devices. Next.
                                          • Select "new main.qml file". Next.
                                          • Click next on the summary page. Next.

                                          Now you will have a .pro-file based project that displays a freshly generated main.qml file. Copy your existing qml files and resources into the project folder into qml/PROJECTNAME and rename your main qml file to main.qml there. Do Build->Run qmake to force a refresh of the file list in the Makefiles. It should pick these changes up automatically, but it may take a while for it to do so.

                                          You should now be able to build and run it by clicking on the play button in the lower left of the creator window. You can of course also open the .pro file with the visual studio plugin and build it there.

                                          For mobile devices you can now create packages of all the contents which are nice and easy to deploy... but for the desktop you get an executable but all the QML files, images, etc. still need to get copied to a place where the exe actually finds them.

                                          So unfortunately you do not gain much to just copying the qmlviewer (which actually is the program used by creator to preview your QML files) plus your qml files and resources in your use case. In both cases you will need to put the required libraries next to the executable (in windows, Linux usually has Qt packages installed in the system and picks up libraries in a different way, too). This does include the various plugins Qt uses... most straight forward way is to just copy everything in the lib/ directory found in your Qt.

                                          Please consider filing a feature request describing your use case in "our bug tracker":http://bugreports.qt.nokia.com/. I think this is certainly a valid use case and we should improve creator to handle it better.

                                          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