[Qt-qml] why does signal clicked (MouseEvent mouse) not parse
Bartosh Wroblevksy
bartosh at live.com
Mon Dec 6 01:09:15 CET 2010
Thanks, but I was hoping I can do something like this:
//Example Button ComponentItem {id: rootElementsignal clicked(MouseEvent mouse)...MouseArea {anchors.fill: parentonClicked: {rootElement.clicked( mouse );}}}
Thanks,Bartosh
> From: david.fishlock at nokia.com
> To: bartosh at live.com; qt-qml at trolltech.com
> Date: Sun, 5 Dec 2010 14:30:23 +0100
> Subject: RE: [Qt-qml] why does signal clicked (MouseEvent mouse) not parse
>
> Hi Bartosh,
> Mouse events in QML should be handled using a MouseArea component, and then the signal should be passed to the parent component when necessary. I am assuming you are creating a custom UI component that needs to have a clicked signal, so here would be a typical example:
>
> //Example Button Component
> Item {
> id: rootElement
> signal clicked
>
> ...
>
> MouseArea {
> anchors.fill: parent
> onClicked: {
> rootElement.clicked();
> }
> }
> }
>
> Define the signal on the root element of the component and create a MouseArea where you want the clickable area, in this example I have ensured that it fills the boundaries of the control with anchors.fill. When the clicked event is detected on this MouseArea, it calls the clicked signal on the root element, and this can be handled in your application view in exactly the same way as shown in the MouseArea here.
>
> SomeCustomComponent {
> onClicked: {
> //execute some code here
> }
> }
>
> If you need control over what types of click you are handling (right mouse button, key mods etc) there is some good info in the QML elements docs:
> http://doc.qt.nokia.com/4.7.old/qml-mouseevent.html
>
> Cheers,
> David
> ________________________________________
> From: qt-qml-bounces at trolltech.com [qt-qml-bounces at trolltech.com] On Behalf Of ext Bartosh Wroblevksy [bartosh at live.com]
> Sent: 05 December 2010 01:05
> To: qt-qml at trolltech.com
> Subject: Re: [Qt-qml] why does signal clicked (MouseEvent mouse) not parse
>
> Hi,
>
> I am bit confused. why does this line not parse in QML, Qt 4.7.0
>
> signal clicked (MouseEvent mouse)
>
> I get this message:
>
> Expected parameter type signal clicked (MouseEvent mouse)
> ^
>
> How am I supposed to propagate a MouseEvent if I can't do this?
>
> Thanks
> Bartosh
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt.nokia.com/pipermail/qt-qml/attachments/20101205/85fcb3cf/attachment.html
More information about the Qt-qml
mailing list