Access to the internal component of an element

I have the following qml file:

import QtQuick 1.0 Component{ Column{ id: interHeader; Item{ id:interItem height: 300 width: 200 Text{ id:title text:"Text" anchors.centerIn: parent font.bold: true elide:"ElideRight" color: "Black" } } Item { width: parent.width height: 100 //onClick event MouseArea { anchors.fill: parent onClicked:{ console.log("Ok"); } } } } } 

The problem is that I need to assign some KeyNavigation to interItem. I want to access interItem from another qml file. How can I do that?

+4
source share
1 answer

There is actually no benefit in using Component in a completely separate QML file. Remove the component and name your Qml file with an uppercase letter - for example. Interheader

Then define a property under your root element. For instance:

 import QtQuick 1.0 Item { id: interHeader property variant keyActionUp Keys.onUpPressed: keyActionUp } 

OR

You can use the Connections function to make callbacks for signals from InterHeader.

http://doc.qt.nokia.com/4.7-snapshot/qml-connections.html

+2
source

All Articles