
Originally Posted by
doulos
looks not bad, actually

. At least at first sight I can see how this might fit my bill. It seems that wrapping ones head around this paradigm is not as easy as one would think. There are several things in your code which can understand when I read them, but don't see how I would have come up with them. I am not in my Qt office right now, so I will try it out tomorrow and report. Thanks much so far
Here is an actually working code:
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
property list<NavigationTile> tiles
default property alias __tiles: root.tiles
Rectangle {
id: outer
Rectangle {
id: inner
}
}
GridLayout {
id: grid
columnSpacing: rowSpacing
anchors.fill: parent
Repeater {
model: root.tiles
Item {
anchors.margins: root.cellPadding
implicitWidth: 100
implicitHeight: 100
Image {
anchors.fill: parent
source: modelData.image
z: 1
}
Rectangle {
anchors.fill: parent
color: modelData.color
}
Layout.rowSpan: modelData.rowSpan
Layout.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
property list<NavigationTile> tiles
default property alias __tiles: root.tiles
Rectangle {
id: outer
Rectangle {
id: inner
}
}
GridLayout {
id: grid
columnSpacing: rowSpacing
anchors.fill: parent
Repeater {
model: root.tiles
Item {
anchors.margins: root.cellPadding
implicitWidth: 100
implicitHeight: 100
Image {
anchors.fill: parent
source: modelData.image
z: 1
}
Rectangle {
anchors.fill: parent
color: modelData.color
}
Layout.rowSpan: modelData.rowSpan
Layout.columnSpan: modelData.columnSpan
}
}
}
}
To copy to clipboard, switch view to plain text mode
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
And main qml file:
import QtQuick 2.2
NavigationPanel {
width: 600
height: 400
columns: 2
rows: 2
NavigationTile {
color: "red"
image: "/usr/share/icons/default.kde4/64x64/apps/kde.png"
rowSpan: 2
}
NavigationTile {
color: "yellow"
image: "/usr/share/icons/default.kde4/64x64/apps/kontact.png"
}
NavigationTile {
color: "orange"
image: "/usr/share/icons/default.kde4/64x64/apps/ktip.png"
}
}
import QtQuick 2.2
NavigationPanel {
width: 600
height: 400
columns: 2
rows: 2
NavigationTile {
color: "red"
image: "/usr/share/icons/default.kde4/64x64/apps/kde.png"
rowSpan: 2
}
NavigationTile {
color: "yellow"
image: "/usr/share/icons/default.kde4/64x64/apps/kontact.png"
}
NavigationTile {
color: "orange"
image: "/usr/share/icons/default.kde4/64x64/apps/ktip.png"
}
}
To copy to clipboard, switch view to plain text mode
what if I insisted on doing this in C++? Just joking..
Then I would continue to say it was an overkill and a waste of effort. I don't know which part you'd want to do in C++.
At this pace we'll have implemented a complete Metro UI by the end of next week...
Bookmarks