I have following ListView:
import QtQuick 2.5
import QtQuick.Layouts 1.2
import si.mikroelektronika 1.0
Item
{
id: ueCategorySelector
clip: true
Rectangle
{
id: ueCategorySelectorWrapper
radius: 16
gradient: Gradient
{
GradientStop
{
position: 0
color: "#ffffff"
} // GradientStop
GradientStop
{
position: 1
color: "#000000"
} // GradientStop
} // Gradient
border.color: "#4682b4"
border.width: 1
antialiasing: true
anchors.fill: parent
ColumnLayout
{
anchors.margins: parent.radius/2
spacing: 0
antialiasing: true
anchors.fill: parent
ListView
{
id: ueCategoryListView
antialiasing: true
orientation: ListView.Horizontal
clip: true
Layout.fillWidth: true
Layout.fillHeight: true
Layout.alignment: Qt.AlignHCenter|Qt.AlignVCenter
Layout.margins: 8
spacing: 8
populate: Transition
{
NumberAnimation
{
property: "opacity"
from: 0
to: 1
duration: 100
} // NumberAnimation
}
Component.onCompleted:
{
model=ueCategoriesModel
} // Component.onCompleted
delegate: Rectangle
{
id: ueCategorySelectorDelegate
radius: 16
width: 256
height: ueCategoryListView.height-2*Layout.margins
clip: true
border.color: "#4682b4"
antialiasing: true
gradient: Gradient
{
GradientStop
{
position: 0
color: "#000000"
ParallelAnimation on color
{
id: ueCategorySelectorColorAnimation
loops: 1
running: false
ColorAnimation
{
from: "#4682b4"
to: "#000000"
duration: 100
} // ColorAnimation
} // ParallelAnimation
} // GradientStop
GradientStop
{
position: 1
color: "#ffffff"
} // GradientStop
} // Gradient
MouseArea
{
id: ueDelegateMouseArea
anchors.fill: parent
onClicked:
{
ueCategorySelectorColorAnimation.running=true;
ueProductsModel.ueUpdateProducts(model.ueRoleId)
ueProductSelectorOpacityAnimator.running=true;
ueCategoryListView.currentIndex=index
} // onClicked
} // MouseArea
ColumnLayout
{
anchors.fill: parent
antialiasing: true
spacing: 8
Image
{
Layout.fillWidth: true
Layout.fillHeight: true
Layout.alignment: Qt.AlignHCenter|Qt.AlignTop
Layout.topMargin: ueCategorySelectorWrapper.radius+4
fillMode: Image.PreserveAspectFit
horizontalAlignment: Image.AlignHCenter
verticalAlignment: Image.AlignVCenter
antialiasing: true
source: "image://ueCategoriesModel/"+model.ueRoleImage
} // Image
Text
{
Layout.fillWidth: true
Layout.fillHeight: true
Layout.alignment: Qt.AlignHCenter|Qt.AlignBottom
Layout.bottomMargin: ueCategorySelectorWrapper.radius+4
color: "#000000"
text: model.ueRoleName
wrapMode: Text.WordWrap
font.family: "Courier"
textFormat: Text.RichText
font.bold: true
font.pointSize: 10
horizontalAlignment: Text.AlignHCenter
verticalAlignment: Text.AlignVCenter
} // Text
} // ColumnLayout
} // delegate
} // ListView
} // ColumnLayot
} // Rectangle
ListView.onAdd:
{
print("Add")
}
} // Item
import QtQuick 2.5
import QtQuick.Layouts 1.2
import si.mikroelektronika 1.0
Item
{
id: ueCategorySelector
clip: true
Rectangle
{
id: ueCategorySelectorWrapper
radius: 16
gradient: Gradient
{
GradientStop
{
position: 0
color: "#ffffff"
} // GradientStop
GradientStop
{
position: 1
color: "#000000"
} // GradientStop
} // Gradient
border.color: "#4682b4"
border.width: 1
antialiasing: true
anchors.fill: parent
ColumnLayout
{
anchors.margins: parent.radius/2
spacing: 0
antialiasing: true
anchors.fill: parent
ListView
{
id: ueCategoryListView
antialiasing: true
orientation: ListView.Horizontal
clip: true
Layout.fillWidth: true
Layout.fillHeight: true
Layout.alignment: Qt.AlignHCenter|Qt.AlignVCenter
Layout.margins: 8
spacing: 8
populate: Transition
{
NumberAnimation
{
property: "opacity"
from: 0
to: 1
duration: 100
} // NumberAnimation
}
Component.onCompleted:
{
model=ueCategoriesModel
} // Component.onCompleted
delegate: Rectangle
{
id: ueCategorySelectorDelegate
radius: 16
width: 256
height: ueCategoryListView.height-2*Layout.margins
clip: true
border.color: "#4682b4"
antialiasing: true
gradient: Gradient
{
GradientStop
{
position: 0
color: "#000000"
ParallelAnimation on color
{
id: ueCategorySelectorColorAnimation
loops: 1
running: false
ColorAnimation
{
from: "#4682b4"
to: "#000000"
duration: 100
} // ColorAnimation
} // ParallelAnimation
} // GradientStop
GradientStop
{
position: 1
color: "#ffffff"
} // GradientStop
} // Gradient
MouseArea
{
id: ueDelegateMouseArea
anchors.fill: parent
onClicked:
{
ueCategorySelectorColorAnimation.running=true;
ueProductsModel.ueUpdateProducts(model.ueRoleId)
ueProductSelectorOpacityAnimator.running=true;
ueCategoryListView.currentIndex=index
} // onClicked
} // MouseArea
ColumnLayout
{
anchors.fill: parent
antialiasing: true
spacing: 8
Image
{
Layout.fillWidth: true
Layout.fillHeight: true
Layout.alignment: Qt.AlignHCenter|Qt.AlignTop
Layout.topMargin: ueCategorySelectorWrapper.radius+4
fillMode: Image.PreserveAspectFit
horizontalAlignment: Image.AlignHCenter
verticalAlignment: Image.AlignVCenter
antialiasing: true
source: "image://ueCategoriesModel/"+model.ueRoleImage
} // Image
Text
{
Layout.fillWidth: true
Layout.fillHeight: true
Layout.alignment: Qt.AlignHCenter|Qt.AlignBottom
Layout.bottomMargin: ueCategorySelectorWrapper.radius+4
color: "#000000"
text: model.ueRoleName
wrapMode: Text.WordWrap
font.family: "Courier"
textFormat: Text.RichText
font.bold: true
font.pointSize: 10
horizontalAlignment: Text.AlignHCenter
verticalAlignment: Text.AlignVCenter
} // Text
} // ColumnLayout
} // delegate
} // ListView
} // ColumnLayot
} // Rectangle
ListView.onAdd:
{
print("Add")
}
} // Item
To copy to clipboard, switch view to plain text mode
Why does ListView not call populate transition?
Sincerely,
Marko
Bookmarks