qt - Can I extend component's MouseArea in main.qml? -
if declare mousearea in sidebarmenubutton.qml component this:
import qtquick 2.3 import qtquick.controls 1.2 import qtquick.controls.styles 1.2 button { width: buttonnewmessage.width height: buttonnewmessage.height anchors { horizontalcenter: parent.horizontalcenter topmargin: 5 } style: buttonstyle { background: rectangle { color: 'transparent' } label: text { text: control.text color: 'white' font.family: 'helvetica' font.pixelsize: 12 font.bold: true verticalalignment: text.alignvcenter horizontalalignment: text.alignleft } } mousearea { anchors.fill: parent cursorshape: "pointinghandcursor" } }
and use in main.qml this:
sidebarmenubutton { id: buttoninbox text: 'inbox' anchors.top: buttonnewmessage.bottom mousearea { anchors.fill: parent onclicked: { newmessagecontainer.visible = false; inboxcontainer.visible = true; } } }
then button in main.qml overrides mousearea of sidebarmenubutton.qml can extend mousearea instead of overriding it?
the question : "why put mousearea on 1 exists in button, instead of re-using ? , more, why put mousearea in button component, has own one".
if need able use onclicked: { ... }
in main.qml, need forward signal, declare signal clicked ();
in custom component , trigger inner mousearea, you'll able catch outside.
but i'm still thinking in code plain wrong...
Comments
Post a Comment