Solved qml button clicked not triggered in *.qml file
-
I created a simple Qt quick UI with button , where the Ui is seperated into Test.qml and TestForm.ui.qml files. I have added the button.onClicked function in the Test.qml file , but the onclicked function is not getting triggered. When I tried to move the onClicked function to TestForm.ui.qml file it is working
How to fix this issue ?
I have added the code which I tried
main.qml
import QtQuick 2.11
import QtQuick.Window 2.11
import QtQuick.Controls 2.15Window {
width: 640
height: 480
visible: true
title: qsTr("Hello World")StackView { id: stackView anchors.fill: parent initialItem: "TestForm.ui.qml" }
}
Test.qml
import QtQuick 2.4
import QtQuick.Controls 2.15TestForm {
anchors.fill: parent button.onClicked: { console.log("button clicked") }
}
TestForm.ui.qml
import QtQuick 2.4
import QtQuick.Controls 2.15Item {
width: 400
height: 400
property alias button: buttonButton { id: button x: 130 y: 135 text: qsTr("Button") }
}
-
hi
@James-A said in qml button clicked not triggered in *.qml file:initialItem: "TestForm.ui.qml"
should be initialItem: "Test.qml"
-
Thank you , This solved the issue