qml - Add dynamically button with click event -
i implemeting multiple add button programmatically. sucessfully add button can't able click event button. getting click on last added button.
i want separately click event button.
i using code add button.
componentdefinition { id: mcomponentdefinitionsubmitbutton button { id: mbuttonid horizontalalignment: horizontalalignment.center onclicked: { //my click code. detect last button. } } } var mbutton = mcomponentdefinitionsubmitbutton.createobject(); mbutton.text = qstr(title) mcontainerbutton.add(mbutton)
i done signal..
function checkclick(button) { console.debug("click..."+ button); } attachedobjects: [ componentdefinition { id: mcomponentdefinitionsubmitbutton button { id: mbuttonid signal click(variant text); horizontalalignment: horizontalalignment.center onclicked: { click(mbuttonid.text); } } } ] ---------------------------------------------------------------- var mbutton = mcomponentdefinitionsubmitbutton.createobject(); mbutton.text = qstr("button"); mbutton.click.connect(checkclick); btncontainer.add(mbutton);
Comments
Post a Comment