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. How to integrate QML and C++
Forum Updated to NodeBB v4.3 + New Features

How to integrate QML and C++

Scheduled Pinned Locked Moved General and Desktop
15 Posts 2 Posters 3.0k 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.
  • K Offline
    K Offline
    karti gesar
    wrote on last edited by
    #2

    my question if i press any button in qml i want to quit that view back to the dialog

    1 Reply Last reply
    0
    • p3c0P Offline
      p3c0P Offline
      p3c0
      Moderators
      wrote on last edited by p3c0
      #3

      @karti-gesar
      Is it QDialog from Cpp and are you talking about QQuickView or QQuickWidget?
      How did you call QQuickView from QDialog ?

      157

      1 Reply Last reply
      1
      • K Offline
        K Offline
        karti gesar
        wrote on last edited by
        #4

        dialog in cpp and Qtquick in qml

        1 Reply Last reply
        0
        • K Offline
          K Offline
          karti gesar
          wrote on last edited by
          #5

          view =new QQuickView();
          view->setSource(QUrl("qrc:/icons/main.qml"));
          imgsource<<"file:///E:/additional's/file4.jpg";
          view->show();
          when button is pressed this some or this will shown

          K 1 Reply Last reply
          0
          • K karti gesar

            view =new QQuickView();
            view->setSource(QUrl("qrc:/icons/main.qml"));
            imgsource<<"file:///E:/additional's/file4.jpg";
            view->show();
            when button is pressed this some or this will shown

            K Offline
            K Offline
            karti gesar
            wrote on last edited by
            #6

            image will be shown in qml window

            1 Reply Last reply
            0
            • K Offline
              K Offline
              karti gesar
              wrote on last edited by
              #7

              my question is when press any key in qml i want to get that dialog window

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

                Keys.onPressed: {
                if (event.modifiers & Qt.ControlModifier)
                {
                console.log("qml");
                //when press any here i want to hide the view window
                }

                1 Reply Last reply
                0
                • p3c0P Offline
                  p3c0P Offline
                  p3c0
                  Moderators
                  wrote on last edited by p3c0
                  #9

                  @karti-gesar If I understood you correctly you want a way to close the QQuickView window using the Keys item in the QML loaded by that QQuickView. If so then there is a global Qt object that provides a quit method. As its description says you just have to connect that signal to your QQuickView's QQmlEngine and then call close on QQuickView.
                  Eg.
                  QML

                  Keys.onPressed: {
                    ...
                    Qt.quit()
                    ...
                  }
                  

                  CPP

                  view =new QQuickView;
                  connect(view->engine(), SIGNAL(quit()), view, SLOT(close()));
                  or
                  connect(view->engine(), &QQmlEngine::quit, view, &QQuickView::close);
                  

                  Hope this helps...

                  157

                  1 Reply Last reply
                  1
                  • K Offline
                    K Offline
                    karti gesar
                    wrote on last edited by
                    #10

                    i will try it

                    1 Reply Last reply
                    0
                    • K Offline
                      K Offline
                      karti gesar
                      wrote on last edited by
                      #11

                      hereIn Qt.quit() Qt is the id name ah

                      1 Reply Last reply
                      0
                      • p3c0P Offline
                        p3c0P Offline
                        p3c0
                        Moderators
                        wrote on last edited by
                        #12

                        @karti-gesar No. It is the global object available across all QML files.
                        http://doc.qt.io/qt-5/qml-qtqml-qt.html

                        157

                        1 Reply Last reply
                        1
                        • K Offline
                          K Offline
                          karti gesar
                          wrote on last edited by
                          #13

                          not working

                          1 Reply Last reply
                          0
                          • p3c0P Offline
                            p3c0P Offline
                            p3c0
                            Moderators
                            wrote on last edited by
                            #14

                            @karti-gesar Try import QtQml 2.2

                            157

                            K 1 Reply Last reply
                            1
                            • p3c0P p3c0

                              @karti-gesar Try import QtQml 2.2

                              K Offline
                              K Offline
                              karti gesar
                              wrote on last edited by
                              #15

                              @p3c0 i will try

                              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