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. [QML+Qt CPP] How to move from Screen-to-Screen in an application?
Forum Updated to NodeBB v4.3 + New Features

[QML+Qt CPP] How to move from Screen-to-Screen in an application?

Scheduled Pinned Locked Moved General and Desktop
13 Posts 3 Posters 6.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.
  • I Offline
    I Offline
    inblueswithu
    wrote on last edited by
    #3

    Thankyou. :)
    Let me check that. On a quick glance of that page it completely deals with how to handle data & signals b/w QML & CPP. Thats good.

    But what is the solution for my screens :(

    1 Reply Last reply
    0
    • T Offline
      T Offline
      t3685
      wrote on last edited by
      #4

      Well, what I would do is to expose the "state" of each screen. Each QML screen that take reads the state and do what they need to do :)

      1 Reply Last reply
      0
      • I Offline
        I Offline
        inblueswithu
        wrote on last edited by
        #5

        Can you just show some sample code so that I can understand. I tried seeing states property in QML but could not find a way. It largely speaks about property changes and change in positioning etc. But I could not find changing b/w completely different screens.
        [quote author="t3685" date="1379618855"]Well, what I would do is to expose the "state" of each screen. Each QML screen that take reads the state and do what they need to do :)[/quote]

        1 Reply Last reply
        0
        • T Offline
          T Offline
          t3685
          wrote on last edited by
          #6

          I am not talking about using QML states. But rather, your C++ could for example remember what the last artists was that was selected and expose that as property.
          When the approriate QML screen is loaded, it will ask the C++ for last selected artists and show the appropriate content.

          1 Reply Last reply
          0
          • I Offline
            I Offline
            inblueswithu
            wrote on last edited by
            #7

            I understand what you said. But I don't think my implementation (not yet done, in abstract stage) is going to be capable that way.
            At this stage leave the state of that screen (for making work easy). At least I should know how to switch b/w the screens.

            1 Reply Last reply
            0
            • I Offline
              I Offline
              inblueswithu
              wrote on last edited by
              #8

              @t3685: After reading the article you "said":http://qt-project.org/doc/qt-5.0/qtqml/qtqml-cppintegration-exposecppattributes.html. I understood how we can expose properties into QML. This method is really useful when we want to create custom types into QML by registering with QML type system. Thank you for showing such a good article.

              But here my requirement is quite simple. I just want to fill in data into QML elements (like Text, List, Grid etc). This would be easy by just getting the object from the QML file & setting them accordingly. Both ways (one you said & the one i'm using) have to handle the objects for each of Text/List/Image/Grid etc from C++. So, I would consider the method I'm using now is easy. Because, I need not have to create classes for each of these (Grouped Texts/List/Grid etc) again (which is a hectic job) and make them available in context, from there qml will use them directly.

              Am I missing something??

              Coming back to my question.. Any ideas?

              1 Reply Last reply
              0
              • T Offline
                T Offline
                t3685
                wrote on last edited by
                #9

                You just need to create one C++ class for each screen. You don't need to create a class for each element. Play around and see what you find is easiest. I don't have experience using your way, so if you want to continue like that you'll have to be creative :)

                1 Reply Last reply
                0
                • V Offline
                  V Offline
                  vladstelmahovsky
                  wrote on last edited by
                  #10
                  1. Use StackView of Qt Quick Controls

                  2. I'm using differen approach for starting qml file:
                    @ QQmlApplicationEngine *engine = new QQmlApplicationEngine;

                    if (!engine) {
                    qDebug() << "Error creating QQmlApplicationEngine";
                    return 1;
                    }
                    QQmlContext *context = engine->rootContext();
                    context->setContextProperty("settings", &settings);

                    engine->load(QUrl("qml/Program/main.qml"));

                    QObject *topLevel = engine->rootObjects().value(0);
                    QQuickWindow *window = qobject_cast<QQuickWindow *>(topLevel);
                    if ( !window ) {
                    qWarning("Error: Your root item has to be a Window.");
                    return -1;
                    }

                    window->show();
                    return app.exec();@

                  1 Reply Last reply
                  0
                  • I Offline
                    I Offline
                    inblueswithu
                    wrote on last edited by
                    #11

                    [quote author="t3685" date="1379689723"]You just need to create one C++ class for each screen.[/quote] True :) It seems good. I'll try once.

                    1 Reply Last reply
                    0
                    • I Offline
                      I Offline
                      inblueswithu
                      wrote on last edited by
                      #12

                      @vladstelmahovsky: I'm using the way as in "QtQuick2 Built In types" while creating a new project in QtCreator.
                      How is the way you told is different from the one I'm using? Which is advantageous.

                      1 Reply Last reply
                      0
                      • V Offline
                        V Offline
                        vladstelmahovsky
                        wrote on last edited by
                        #13

                        you have more control over engine, context and root object

                        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