Good evening everyone, I’m new to these forums, however I’ve been reading and enjoying all of the knowledge shared here to date!
I’m having some problems here with using a MouseArea inside of a Text as a delegate of a Repeater. The problem that I seem to be having is that the MouseArea ends up only being accessible across the top pixel of the Text extending the whole length of the Text.
Can anyone help me shed some light on this please? Thanks so much in advance, as I appreciate and respect the advice of the users on here!
Here’s my problematic code…
Rectangle {
width: 1000
height: 42
clip: true
ListModel {
id: breadCrumb
ListElement {
name: "Home"
}
}
FlowView {
model: breadCrumb
anchors.fill: parent
width: parent.width
height: parent.height
delegate: Item {
width: textBlock.paintedWidth + 10
height: textBlock.paintedHeight
Rectangle {
id: rect
anchors.fill: parent
//width: parent.width
//height: parent.height
anchors.margins: 8
Text {
id: textBlock
anchors.fill: parent
text: name
font.pixelSize: 20
//anchors.centerIn: parent
MouseArea {
anchors.fill: parent
hoverEnabled: true
onEntered: { console.log("entered") }
}
}
}
}
}
}
And here is my FlowView.qml
import QtQuick 1.1
Flickable {
id: flowView
anchors.fill: parent
boundsBehavior: Flickable.DragOverBounds
flickableDirection: Flickable.HorizontalFlick
contentWidth: parent.width
contentHeight: flow.childrenRect.height
property alias count: flowRepeater.count
property int currentIndex: -1
property variant currentItem
property alias delegate: flowRepeater.delegate
property alias flow: flow.flow
property alias model: flowRepeater.model
onCurrentIndexChanged: {
currentItem = model.get(currentIndex)
}
Flow {
id: flow
//width: parent.width
//height: parent.height
Repeater {
id: flowRepeater
model: flowView.model
onCountChanged: {
if (flowView.currentIndex === -1 && count > 0) {
flowView.currentIndex = 0
}
if (flowView.currentIndex >= count) {
flowView.currentIndex = count - 1
}
}
}
}
}
↧