set properties from listView
This commit is contained in:
parent
f2fd2e880a
commit
693078b892
3 changed files with 14 additions and 10 deletions
|
|
@ -37,12 +37,14 @@ Item {
|
|||
model: navigationList.pModelItems
|
||||
spacing: 20
|
||||
orientation: ListView.Horizontal
|
||||
delegate:
|
||||
NavigationListDelegate{
|
||||
delegate: NavigationListDelegate{
|
||||
id: delegate
|
||||
property var delegateModel: navigationList.pModelItems[index]
|
||||
height: parent.height
|
||||
width: height
|
||||
model: navigationList.pModelItems[index]
|
||||
isCircleDelegate: delegateModel.pIsCircleDelegate
|
||||
imageSource: delegateModel.pImageSource
|
||||
onClicked: delegateModel.onClicked();
|
||||
} // NavigationListDelegate
|
||||
} // ListView
|
||||
} // Rectangle: List background
|
||||
|
|
|
|||
|
|
@ -2,27 +2,29 @@ import QtQuick 2.11
|
|||
import QtQuick.Controls 2.4
|
||||
import QtGraphicalEffects 1.0
|
||||
|
||||
/**
|
||||
* @brief Delegate of navigation list.
|
||||
*
|
||||
* The delegate is either a circle or a rectangle containing an image.
|
||||
*/
|
||||
ItemDelegate{
|
||||
id: container
|
||||
|
||||
property var model
|
||||
property bool isCircleDelegate: true
|
||||
property alias imageSource: contentImage.source
|
||||
|
||||
|
||||
padding: 5
|
||||
onClicked:{
|
||||
model.onClicked();
|
||||
}
|
||||
|
||||
background: Rectangle{
|
||||
id: background
|
||||
implicitWidth: 150
|
||||
implicitHeight: implicitWidth
|
||||
radius: model.pIsCircleDelegate ? height/2 : 0
|
||||
radius: container.isCircleDelegate ? height/2 : 0
|
||||
color: "blue"
|
||||
Image{
|
||||
id: contentImage
|
||||
source: model ? model.pImageSource : "qrc:/default_image"
|
||||
source: "qrc:/default_image"
|
||||
anchors.fill: parent
|
||||
anchors.margins: 5
|
||||
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@
|
|||
|
||||
NavigationListModel::NavigationListModel(QObject* parent) : QObject(parent)
|
||||
{
|
||||
|
||||
/*nothing*/
|
||||
}
|
||||
|
||||
QList<QObject *> NavigationListModel::getModelItems()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue