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 integrate c++ and qt quick(qml)
Forum Updated to NodeBB v4.3 + New Features

How to integrate c++ and qt quick(qml)

Scheduled Pinned Locked Moved QML and Qt Quick
18 Posts 6 Posters 13.1k 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.
  • V Offline
    V Offline
    vsorokin
    wrote on last edited by
    #8

    You need widget, try this:
    @
    #include <QtDeclarative/QDeclarativeView>
    ...
    QDeclarativeView *view = new QDeclarativeView;
    view->setSource(QUrl::fromLocalFile("myqmlfile.qml"));
    mainWindow->setCentralWidget(view);

    view->show();@

    --
    Vasiliy

    1 Reply Last reply
    0
    • I Offline
      I Offline
      imrrk
      wrote on last edited by
      #9

      ixsci

      I tried this from the link u gave...can you soty out the errors

      1 Reply Last reply
      0
      • I Offline
        I Offline
        ixSci
        wrote on last edited by
        #10

        Your code has one C++ mistake:QDeclarativeItem* item = qobject_cast<QDeclarativeItem*>(myObject);
        You will see nothing with your corrected code though. You must create scene for showing QML in it. I have no handy example for this but Vass presented simplified way to show QML in C++ code. Just follow the Vass code. When you master it you can move further to more complex examples with your own created scenes, if you will need any. But at the moment it would be better to use pre-created QDeclarativeView for comprehending rudiments of C++ and QML relationship.

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

          ixsci

          Ok wait i will try out vass code and let you know

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

            ixsci

            By using Vass code

            I getting fllowing errors
            1.C:\Qt\qtcreator-2.0.94\intgmobile-build-simulator/../intgmobile/main.cpp:14: error: undefined reference to `_imp___ZN16QDeclarativeViewC1EP7QWidget'

            2.C:\Qt\qtcreator-2.0.94\intgmobile-build-simulator/../intgmobile/main.cpp:18: error: undefined reference to `_imp___ZN16QDeclarativeView9setSourceERK4QUrl'

            3.:-1: error: collect2: ld returned 1 exit status

            1 Reply Last reply
            0
            • I Offline
              I Offline
              imrrk
              wrote on last edited by
              #13

              hello vass

              I am getting the above errors by using ur code..

              so please sort it out

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

                imrrk, add
                @QT += declarative@
                to your .pro file.

                P.S. And please don't multipost.

                1 Reply Last reply
                0
                • I Offline
                  I Offline
                  imrrk
                  wrote on last edited by
                  #15

                  Hi everyone
                  I tried with all the possibilities listed here...the example works fine in simulator but when i try to deploy it on device using Nokia Qt SDK i m getting error as follows

                  1.DeclarativeView no such file or directory

                  1 Reply Last reply
                  0
                  • V Offline
                    V Offline
                    vsorokin
                    wrote on last edited by
                    #16

                    imrrk What i version of Qt on your device? For Qt quick you need install "developers build Qt 4.7":http://wiki.forum.nokia.com/index.php/Qt_4.7_for_Symbian^3_-_developer_version.

                    --
                    Vasiliy

                    1 Reply Last reply
                    0
                    • M Offline
                      M Offline
                      mohsen
                      wrote on last edited by
                      #17

                      Hello,
                      I had same problem with WinCE. You should manually copy QtDeclarative, QtNetwork, QtScript and QtSql libraries to device when you use QML in your project. Also make sure you're using the latest QtSDK version.

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

                        [quote author="imrrk" date="1293685687"]Hi everyone
                        I tried with all the possibilities listed here...the example works fine in simulator but when i try to deploy it on device using Nokia Qt SDK i m getting error as follows

                        1.DeclarativeView no such file or directory
                        [/quote]

                        The latest Nokia Qt SDK available has support for Qt 4.6 only for release builds. So you cannot build QML app release with this SDK.

                        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