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

Forwarding QML property to C++

Scheduled Pinned Locked Moved Solved General and Desktop
5 Posts 3 Posters 1.1k Views 2 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.
  • H Offline
    H Offline
    herlarbee
    wrote on last edited by
    #1

    A Little help here, I Intend using the "textDocument" property of the TextArea document in my C++ Code via QTextDocument.
    I obviously don't want to make calls to search and transverse my object tree via rootObjects().at(index) and findChild() methods as i find them a lot less flexible and twingy to the eye.
    Is there a cleaner and more flexible way to expose a QML Elements property to C++.
    PS: I don't infer that calling C++ from QML using ** registertype**. I mean using exposing QML element property(s) to C++

    1 Reply Last reply
    0
    • VRoninV Offline
      VRoninV Offline
      VRonin
      wrote on last edited by
      #2

      i'm afraid findchild is the way to go: http://doc.qt.io/qt-5/qtqml-cppintegration-interactqmlfromcpp.html

      "La mort n'est rien, mais vivre vaincu et sans gloire, c'est mourir tous les jours"
      ~Napoleon Bonaparte

      On a crusade to banish setIndexWidget() from the holy land of Qt

      1 Reply Last reply
      2
      • H Offline
        H Offline
        herlarbee
        wrote on last edited by
        #3

        Thanks VRonin for the quick response.

        kshegunovK 1 Reply Last reply
        0
        • H herlarbee

          Thanks VRonin for the quick response.

          kshegunovK Offline
          kshegunovK Offline
          kshegunov
          Moderators
          wrote on last edited by
          #4

          @herlarbee
          To add to @VRonin, I advise you to keep a reference to your object in a QPointer, because QObject::findChild traverses the QObject tree recursively and may be rather slow.

          Read and abide by the Qt Code of Conduct

          1 Reply Last reply
          1
          • H Offline
            H Offline
            herlarbee
            wrote on last edited by
            #5

            @Kshegunov Thanks

            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