I don't see a need for any complex imperative code here. I don't know what you have so far so let's try from scratch... BTW. I didn't test the code below, so it can contain minor errors but the general idea should be valid.
NavigationPanel -- contains two rectangles and a grid layout:
import QtQuick 2.2
import QtQuick.Layouts 1.0
Item {
id: root
property alias rows: grid.rows
property alias columns: grid.columns
property alias cellSpacing: grid.rowSpacing
property int cellPadding: 0
default property list<NavigationTile> tiles
Rectangle {
id: outer
Rectangle {
id: inner
}
}
GridLayout {
id: grid
columnSpacing: rowSpacing
Repeater {
model: root.tiles
Item {
margins: root.cellPadding
Image {
anchors.fill: parent
source: modelData.image
}
Rectangle {
anchors.fill: parent
color: modelData.color
}
Layout { rowSpan: modelData.rowSpan; columnSpan: modelData.columnSpan }
}
}
}
}
import QtQuick 2.2
import QtQuick.Layouts 1.0
Item {
id: root
property alias rows: grid.rows
property alias columns: grid.columns
property alias cellSpacing: grid.rowSpacing
property int cellPadding: 0
default property list<NavigationTile> tiles
Rectangle {
id: outer
Rectangle {
id: inner
}
}
GridLayout {
id: grid
columnSpacing: rowSpacing
Repeater {
model: root.tiles
Item {
margins: root.cellPadding
Image {
anchors.fill: parent
source: modelData.image
}
Rectangle {
anchors.fill: parent
color: modelData.color
}
Layout { rowSpan: modelData.rowSpan; columnSpan: modelData.columnSpan }
}
}
}
}
To copy to clipboard, switch view to plain text mode
NavigationTile -- definition of a tile
import QtQuick 2.2
QtObject {
id: tile
property color color
property string image
property int columnSpan: 1
property int rowSpan: 1
property string target
}
import QtQuick 2.2
QtObject {
id: tile
property color color
property string image
property int columnSpan: 1
property int rowSpan: 1
property string target
}
To copy to clipboard, switch view to plain text mode
What's next?
Bookmarks