components - The qml default signal handler cannot work -
---question---
i create "textbtn" component , add signal "btnclicked" in it:
textbtn.qml
import qt 4.7 rectangle { property alias btntext: showstr.text width:100 height:30 border.color: "black" border.width: 1 color: "white" signal btnclicked() //the default signal handler onbtnclicked: console.log(btntext+" clicked.") mousearea { id: btnmousearea anchors.fill: parent onclicked: btnclicked() } text { id: showstr anchors.centerin: parent color: "black" } }
another component "menurow" contains 3 "textbtn"s follows:
menurow.qml
import qt 4.7 row { spacing: 5 textbtn { id: testbtn01 btntext: "test01" } textbtn { id: testbtn02 btntext: "test02" } textbtn { id: testbtn03 btntext: "test03" } }
the default single handler "onbtnclicked" in "textbtn" should triggered when 1 of "textbtn"s in "menurow" clicked, doesn't. what's going on?
the related qml doc here: http://doc.qt.nokia.com/4.7/gettingstartedqml.html#basic-component-a-button
---development environment---
os: ubuntu 10.04
qt version: 4.7.0(use "qt-sdk-linux-x86-opensource-2010.05.1.bin" install qt sdk in default path "$home/qtsdk-2010.05/")
before running qml, source file "qtsetup.sh" set related paths,
$ source qtsetup.sh
qtsetup.sh
qtdir=$home/qtsdk-2010.05/qt/ path=$path:$qtdir/bin ld_library_path=$ld_library_path:$qtdir/lib
then run qml files "qmlviewer".
$ qmlviewer menurow.qml
a qmlviewer window triggered , shows "menurow". no error occurs. use mouse click "textbtn" in "menurow", nothing happens. (it should show message "text0x clicked" in terminal.)
i use qmlviewer run other examples , demos, seem work well. don't know why example cannot work.
the problem happens here (qmlviewer 4.7.0).
looks it's bug in qmlviewer, read follow-ups here.
if remove alias (btntext), signal work. (but proper solution update 4.7.1+)
Comments
Post a Comment