Not getting onClicked in QML code
Solved
QML and Qt Quick
-
Hi All.
I have what is probably a simple problem but I can't figure out the answer. I have a very simple Qt Quick app that has a StackView in main.qml, a button in the .ui.qml file and an onClicked handler in the QML code file. The problem is, onClicked doesn't seem to be getting called.
Any help would be appreciated.
Thanks,
Kevinmain.qml
import QtQuick 2.7 import QtQuick.Window 2.0 import QtQuick.Controls 2.0 import QtQuick.Layouts 1.0 ApplicationWindow { title: qsTr("Where's My Click?") width: 120 height: 60 visible: true StackView { id: stack anchors.fill: parent initialItem: Page1Form { anchors.fill: parent } } }
Page1.qml
import QtQuick 2.7 Page1Form { pressMe.onClicked: { console.log("Button clicked."); } }
Page1Form.ui.qml
import QtQuick 2.7 import QtQuick.Controls 2.0 import QtQuick.Layouts 1.0 Item { property alias pressMe: pressMe anchors.fill: parent Button { id: pressMe anchors.centerIn: parent text: qsTr("Press Me") } }
-
I knew it had to be something simple. :-) Yes, that was it. Newbie here. Thanks for the quick response!