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 find a child item of qquickwidget
Qt 6.11 is out! See what's new in the release blog

How to find a child item of qquickwidget

Scheduled Pinned Locked Moved Solved General and Desktop
2 Posts 1 Posters 655 Views
  • 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.
  • JoeCFDJ Offline
    JoeCFDJ Offline
    JoeCFD
    wrote on last edited by JoeCFD
    #1

    A qml file is loaded into qquickwidget and can be displayed in a qwidget layout. I need to find a child item inside the qml file and use it in the code . I set object name to the item in the qml file. But qquickwidget-> findChild< QObject * > ( objectName ) returns nullptr. What is wrong?

    If I have pure qml layout, there is no problem to find this item from root window.

    JoeCFDJ 1 Reply Last reply
    0
    • JoeCFDJ JoeCFD

      A qml file is loaded into qquickwidget and can be displayed in a qwidget layout. I need to find a child item inside the qml file and use it in the code . I set object name to the item in the qml file. But qquickwidget-> findChild< QObject * > ( objectName ) returns nullptr. What is wrong?

      If I have pure qml layout, there is no problem to find this item from root window.

      JoeCFDJ Offline
      JoeCFDJ Offline
      JoeCFD
      wrote on last edited by JoeCFD
      #2

      @JoeCFD Fixed it by using rootObject = m_quickWidget->rootObject() to find child object;
      auto child_obj = rootObject-> findChild< QObject * > ( objectName ); works.
      while qquickwidget-> findChild< QObject * > ( objectName ) does not work.

      1 Reply Last reply
      1
      • JoeCFDJ JoeCFD has marked this topic as solved on

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved