Skip to content

Instantly share code, notes, and snippets.

@mottosso
Created March 25, 2015 10:52
Show Gist options
  • Select an option

  • Save mottosso/d10f9c71a074420337ad to your computer and use it in GitHub Desktop.

Select an option

Save mottosso/d10f9c71a074420337ad to your computer and use it in GitHub Desktop.
Composite Items in QML

Composite Items in QML

untitled

This is an example of how a Component can be injected into another Component so as to provide for composable items. This allows you to slot components into already established components for greater customisability. One may, for example, act as a shell/skeleton for another.

Usage

Run CompositeItem.qml using qmlscene; there are no other dependencies.

import QtQuick 2.3
Item {
id: composite
property Component body
Row {
anchors.fill: parent
Rectangle {
color: "brown"
width: 50
height: parent.height
}
Loader {
width: parent.width - 50
height: parent.height
sourceComponent: composite.body
}
}
body: Rectangle {
height: 60
color: "steelblue"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment