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. QtQuickTest: add custom C++ objects
Forum Updated to NodeBB v4.3 + New Features

QtQuickTest: add custom C++ objects

Scheduled Pinned Locked Moved General and Desktop
4 Posts 2 Posters 1.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.
  • K Offline
    K Offline
    Korchkidu
    wrote on last edited by
    #1

    Hi,

    in my application, I register custom C++ objects that I use in the GUI afterwards. I would like to unit test my application with QtQuickTest. However, the C++ objects are not found. So how can I register them so that I can use them when unit testing my app with QtQuickTest?¨

    Thanks for any help.
    Best regards.

    1 Reply Last reply
    0
    • M Offline
      M Offline
      messi
      wrote on last edited by
      #2

      Have you read the follwing link:
      http://qt-project.org/wiki/Introduction_to_Qt_Quick_for_Cpp_developers#e70ea8482b12de725ec779f1bc55c92c

      1 Reply Last reply
      0
      • K Offline
        K Offline
        Korchkidu
        wrote on last edited by
        #3

        Hi,

        thanks for the link. It seems to be deprecated however. Also, I am more interested in QtQuickTest framework specifically, not QtQuick in general. Adding custom C++ objects to my QML application already works. But not with QtQuickTest unfortunately.

        1 Reply Last reply
        0
        • M Offline
          M Offline
          messi
          wrote on last edited by
          #4

          Hi
          I know that this link is old. But it hasn't changed in QtQuick 2. The principal is the same.

          Here the up to date link.
          http://qt-project.org/doc/qt-5/qtqml-cppintegration-topic.html

          Now choose the link, Embedding C++ Object in QML.
          http://qt-project.org/doc/qt-5/qtqml-cppintegration-contextproperties.html

          When you register you C++ Object with QmlContext::setContextProperty
          then you should also be able to access your C++ object in QML.

          If this approach doesn't work, post a code example to analyse where the problem might be.

          Best regards

          Juergen

          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