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. How to use "Qt Desktop Components" on Qt5
Forum Updated to NodeBB v4.3 + New Features

How to use "Qt Desktop Components" on Qt5

Scheduled Pinned Locked Moved QML and Qt Quick
11 Posts 4 Posters 4.4k 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.
  • R Offline
    R Offline
    riaank
    wrote on 21 Jan 2013, 11:28 last edited by
    #1

    I am not sure how to build the Qt Desktop Components. It says on the "wiki":http://qt-project.org/wiki/QtDesktopComponents that you should "qmake" and then "make install". I opened the Qt5 command line and ran qmake; all fine. When I run "make install" it says it does not recognize the command. What do I need to do/set/install to make the desktop components.

    1 Reply Last reply
    0
    • S Offline
      S Offline
      sierdzio
      Moderators
      wrote on 21 Jan 2013, 11:58 last edited by
      #2

      You are using Windows, right? There is no "make" on Windows, you need to use nmake/ jom (if your compiler is MSVC) or mingw-make if you are using MinGW.

      I'm not sure Desktop Components are ready for Qt5 and windows anyway. Most Qt developers work on linux.

      (Z(:^

      1 Reply Last reply
      0
      • D Offline
        D Offline
        dmcr
        wrote on 1 Aug 2013, 14:22 last edited by
        #3

        Hello,

        Does someone has tried to use QtDesktopComponents on windows?

        Thanks!

        dmcr

        1 Reply Last reply
        0
        • S Offline
          S Offline
          sierdzio
          Moderators
          wrote on 1 Aug 2013, 14:38 last edited by
          #4

          This project is now integrated into mainline Qt. You can get it by simply downloading Qt 5.1. Search the documentation for QtQuick.Controls module to learn more.

          (Z(:^

          1 Reply Last reply
          0
          • C Offline
            C Offline
            candll
            wrote on 7 Aug 2013, 01:10 last edited by
            #5

            Hi,
            I am unsure how to create a hybrid Cpp + QtQuick 2 + QtQuck Controls project.

            In QtCreator 2.8 there are two project templates of interest: A) "QtQuick 2 UI with Controls" and B) "QtQuick 2 Application - (Built-in types)".

            A) This type of projcect can consist only of QML files, so no C++ here AFAIK.

            B). Consists of a main.cpp, main.qml as well as a qtquick2applicationviewer[.h/.cpp] file.

            In B) Doing an 'import Qt.QuickControls 1.0' inside main.qml is not enough, since according to the documentation found here: http://doc-snapshot.qt-project.org/qt5-stable/qtquickcontrols/qtquickcontrols-overview.html we ought to change the 'main.cpp' file to support them.

            Changing my main.cpp file, from:

            @#include <QApplication>
            #include <QQmlApplicationEngine>

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

            QtQuick2ApplicationViewer viewer;
            viewer.setMainQmlFile&#40;QStringLiteral("qml/untitled/main.qml"&#41;&#41;;
            viewer.showExpanded(&#41;;
            
            return app.exec&#40;&#41;;
            

            }@

            to:

            @#include <QApplication>
            #include <QQmlApplicationEngine>

            int main(int argc, char *argv[])
            {
            QApplication app(argc, argv);
            QQmlApplicationEngine engine("qml/untitled/main.qml");
            return app.exec();
            }@

            fails to compile with: 'QApplication: No such file or directory'

            I don't also know what is supposed to happen with QtQuick2ApplicationViewer which i just have removed from main.cpp and it's corresponding files (header, source). It seems to contain a lot of bootstrap logic. Not to mention there's some specific configuration added to the end of the .pro file that is related to it.

            I'd be very glad if anyone could outline how to start a hybrid C++/QtQuick2 with Controls project.

            1 Reply Last reply
            0
            • S Offline
              S Offline
              sierdzio
              Moderators
              wrote on 7 Aug 2013, 05:47 last edited by
              #6

              You are wrong in your assumption that you need to change anything in main.cpp. Controls are just another QtQuick 2 module, they work out of the box, at least for me. Remember to bump import statements to version 2.1:
              @
              import QtQuick 2.1
              @

              Controls can be easily mixed with standard Quick components. See "this":https://github.com/sierdzio/closecombatfree/blob/master/qml/gui/menus/PreferencesMenu.qml if you are in doubt :)

              As for QtQuick2ApplicationViewer: it's just a thin wrapper around QQuickView. You can safely use the base class, or the new appEngine if you prefer.

              (Z(:^

              1 Reply Last reply
              0
              • C Offline
                C Offline
                candll
                wrote on 7 Aug 2013, 10:21 last edited by
                #7

                At least it's reasurring that not much needs to be changed :).

                Ok, so I create a project via the 'QtQuick 2 Application with Built-in types' button.

                I change main.qml content from:

                @import QtQuick 2.0

                Rectangle {
                width: 360
                height: 360
                Text {
                text: qsTr("Hello World")
                anchors.centerIn: parent
                }
                MouseArea {
                anchors.fill: parent
                onClicked: {
                Qt.quit();
                }
                }
                }@

                to:

                @import QtQuick 2.1
                import QtQuick.Controls 1.0

                ApplicationWindow {
                id: window
                height:500
                width:500

                Button {
                    text: "hello"
                    anchors.centerIn: parent
                    onClicked: {
                      Qt.quit();
                    }
                }
                

                }@

                Unfortunately when I start the application I get an empty white window without any child controls.

                I am on windows, using this Qt 5.1 SDK build (Qt 5.1.0 for Windows 32-bit (MinGW 4.8, OpenGL, 666 MB)).

                The window is empty on QtCreator 2.7.2 that comes with Qt 5.1 as well as the new QtCreator 2.8.

                A project with the exact same main.qml file created via QtQuick 2 UI with Controls displays everything fine :(

                1 Reply Last reply
                0
                • S Offline
                  S Offline
                  sierdzio
                  Moderators
                  wrote on 7 Aug 2013, 10:24 last edited by
                  #8

                  Change ApplicationWindow into a Rectangle.

                  (Z(:^

                  1 Reply Last reply
                  0
                  • C Offline
                    C Offline
                    candll
                    wrote on 7 Aug 2013, 10:45 last edited by
                    #9

                    Should not the root object be an ApplicationWindow? It's the whole point of having QtQuick Controls.

                    I can't even for some reason run http://www.ics.com/blog/integrating-c-qml which is an example of C++/QML integration with QtQuick.Controls since it can't find the main.qml file.

                    I am going to experiment with installing different Qt 5.1 SDKs as something is definitely wrong with the MinGW build I have.

                    1 Reply Last reply
                    0
                    • S Offline
                      S Offline
                      sierdzio
                      Moderators
                      wrote on 7 Aug 2013, 10:51 last edited by
                      #10

                      QQuickView starts the window for you, so there is no need for it.

                      (Z(:^

                      1 Reply Last reply
                      0
                      • C Offline
                        C Offline
                        candll
                        wrote on 7 Aug 2013, 13:32 last edited by
                        #11

                        So I finally figured it out.

                        There's no QtQuick 2 template with C++ integration that supports QtQuick.Controls in QtCreator out of the box as of now (version 2.8).

                        We will have to create an empty Qt project from scratch:

                        1. File -> New File or Project -> Other Project -> Empty Qt Project

                        let's name it 'mytestproject'

                        1. Modify mytestproject.pro by adding this:
                          @
                          TEMPLATE = app
                          TARGET = mytestproject
                          QT += qml quick widgets
                          @

                        2. Add main.qml file to the project
                          @
                          import QtQuick 2.1
                          import QtQuick.Controls 1.0

                        ApplicationWindow {
                        id: rootWindow
                        height: 500
                        width: 500
                        visible: true // <-- this is important because the window is hidden by default
                        Button {
                        text: "Quit app"
                        anchors.centerIn: parent
                        onClicked: {
                        Qt.quit();
                        }
                        }
                        }@

                        1. Add main.cpp file to the project
                          @
                          #include <QApplication>
                          #include <QQmlApplicationEngine>

                        int main(int argc, char** argv)
                        {
                        QApplication app(argc, argv);
                        QQmlApplicationEngine engine("main.qml");
                        app.exec();
                        }
                        @

                        1. Disable Shadow build

                        QtCreator creates a shadow directory by default where it builds our application.

                        i.e if our app is located at:
                        /home/foo/mytestproject

                        then it will create a debug and release directory at:
                        /home/foo/mytestproject-Debug-Desktop
                        /home/foo/mytestproject-Release-Desktop

                        This means that inside 'main.cpp' the QQmlApplicationEngine won't be able to find our 'main.qml' file that we want to load.

                        I don't know any other workaround, so let's just disable the shadow directory feature altogether and let's build our application inside it's folder.

                        To do this click on the large Projects icon on the lefthand side of QtCreator and untick 'Shadow build'.

                        1. Build Run and Enjoy

                        Now the project should be building and we should be seeing a window with a buton.

                        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