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. Single QML page where children are unable to access other siblings
Forum Update on Monday, May 27th 2025

Single QML page where children are unable to access other siblings

Scheduled Pinned Locked Moved Solved QML and Qt Quick
4 Posts 3 Posters 1.7k 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.
  • S Offline
    S Offline
    scotryder
    wrote on last edited by
    #1

    Hi there,

    I have a Simple Page with nested children and one of the child get data from C++ and want to set current Index of a Combobox, but i get undefidend error.

    I tried creating a alias property but failed miserably.

    Page{
    
    
    SomeOther{
    
    
    onC++Event{
    
    
    imnotaccessible.currentIndex = 0;
    undefied error
    
    }
    
    
    }
    
    ListView{
    
    header: Toolbar{
    
         ComboBox{
            
                id: imnotaccessible
    
         }
    
    }
    
    }
    
    }
    

    Please advise
    Thanks

    1 Reply Last reply
    0
    • SR__S Offline
      SR__S Offline
      SR__
      wrote on last edited by
      #2

      @scotryder said in Single QML page where children are unable to access other siblings:

      A simple solution to the problem of access is to set an accessible property from your hierarchy with the id of the inaccessible item when you do have access to it.

      import QtQuick 2.9
      import QtQuick.Window 2.0
      import QtQuick.Controls 2.2
      
      Window
      {
          visible: true
          width: 200
          height: 200
          id:root
          property var anAccessibleItem
          Item
          {
              Rectangle
              {
                  width: 100
                  height: 100
                  color: "red"
                  MouseArea
                  {
                      anchors.fill: parent
                      onClicked: console.info(anAccessibleItem.anInt++)
                  }
              }
          }
          ListView
          {
              header: Item
              {
                  Item
                  {
                      id: imnotaccessible
                      property int anInt: 3
                      Component.onCompleted: root.anAccessibleItem = imnotaccessible
                  }
              }
      
          }
      }
      
      1 Reply Last reply
      1
      • S Offline
        S Offline
        scotryder
        wrote on last edited by
        #3

        Cant thank you enough, it was a pain in the neck and you just solved in an instant.
        Thanks again :)

        1 Reply Last reply
        0
        • Pablo J. RoginaP Offline
          Pablo J. RoginaP Offline
          Pablo J. Rogina
          wrote on last edited by
          #4

          @scotryder please don't forget to mark your post as solved, thank you

          Upvote the answer(s) that helped you solve the issue
          Use "Topic Tools" button to mark your post as Solved
          Add screenshots via postimage.org
          Don't ask support requests via chat/PM. Please use the forum so others can benefit from the solution in the future

          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