Hello!
I am trying to access an alias from an Item and it is not working. Can anyone help me?
In main.qml, when I try DelegateLancamentos.removeMouseArea: it returns this message:
qrc:/DelegateLancamentos.qml:10 Invalid alias reference. Unable to find id "removeMouseArea"
Code below:
MainForm.ui.qml
Rectangle {
id: mainContainer
property alias lancamentosListView: lancamentosListView
width: 360
height: 640
ListView {
id: lancamentosListView
anchors.fill: parent
clip: true
spacing: 10
}
}
Rectangle {
id: mainContainer
property alias lancamentosListView: lancamentosListView
width: 360
height: 640
ListView {
id: lancamentosListView
anchors.fill: parent
clip: true
spacing: 10
}
}
To copy to clipboard, switch view to plain text mode
ModeloLancamentos.qml
ListModel {
ListElement {
valor: "25.000,00"
tipo: "Investimento"
}
}
ListModel {
ListElement {
valor: "25.000,00"
tipo: "Investimento"
}
}
To copy to clipboard, switch view to plain text mode
DelegateLancamentos.qml
Item {
id: delegateItem
property Component delegateComponent: delegateComponent
property alias removeMouseArea: removeMouseArea
Component {
id: delegateComponent
Row {
Column {
width: 360 * 0.96 / 8 * 6
//width: Screen.width * 0.96 / 8 * 6
Text {
text: "<strong>" + "Valor: " + valor + "</strong>"
font.pixelSize: 16
}
Text {
text: "Tipo: " + tipo
font.pixelSize: 16
}
}
Column {
width: 360 * 0.96 / 8
//width: Screen.width * 0.96 / 8
Image {
id: removeImage
source: "Imagens/remove.png"
width: 35
fillMode: Image.PreserveAspectFit
MouseArea {
id: removeMouseArea
anchors.fill: parent
}
}
}
}
}
}
Item {
id: delegateItem
property Component delegateComponent: delegateComponent
property alias removeMouseArea: removeMouseArea
Component {
id: delegateComponent
Row {
Column {
width: 360 * 0.96 / 8 * 6
//width: Screen.width * 0.96 / 8 * 6
Text {
text: "<strong>" + "Valor: " + valor + "</strong>"
font.pixelSize: 16
}
Text {
text: "Tipo: " + tipo
font.pixelSize: 16
}
}
Column {
width: 360 * 0.96 / 8
//width: Screen.width * 0.96 / 8
Image {
id: removeImage
source: "Imagens/remove.png"
width: 35
fillMode: Image.PreserveAspectFit
MouseArea {
id: removeMouseArea
anchors.fill: parent
}
}
}
}
}
}
To copy to clipboard, switch view to plain text mode
main.qml
Window {
visible: true
width: 360
height: 640
maximumHeight: 640
minimumHeight: 640
maximumWidth: 360
minimumWidth: 360
title: "InvestmentC-Mobile"
MainForm {
anchors.fill: parent
mainContainer.width: parent.width
mainContainer.height: parent.height
lancamentosListView.model: modeloLancamentos
lancamentosListView.delegate: delegateLancamentos.delegateComponent
DelegateLancamentos.removeMouseArea:
{
modeloLancamentos.remove(index);
}
}
ModeloLancamentos{
id: modeloLancamentos
}
DelegateLancamentos {
id: delegateLancamentos
}
}
Window {
visible: true
width: 360
height: 640
maximumHeight: 640
minimumHeight: 640
maximumWidth: 360
minimumWidth: 360
title: "InvestmentC-Mobile"
MainForm {
anchors.fill: parent
mainContainer.width: parent.width
mainContainer.height: parent.height
lancamentosListView.model: modeloLancamentos
lancamentosListView.delegate: delegateLancamentos.delegateComponent
DelegateLancamentos.removeMouseArea:
{
modeloLancamentos.remove(index);
}
}
ModeloLancamentos{
id: modeloLancamentos
}
DelegateLancamentos {
id: delegateLancamentos
}
}
To copy to clipboard, switch view to plain text mode
Bookmarks