Hi Merve

To my understanding MouseArea can only be rectangular. And even if it wasn't 
anchors can command only four sides.

What you could try is to have MouseArea covering whole polygon (and some more 
space) and in the mouse event handlers perform a test on whether the mouse 
coordinates are actually inside your polygon.


Best regards,
Artem.

On Aug 15, 2011, at 8:12 PM, merve t wrote:

> Hi,
> i have a custom type, QDeclarativeItem subclass called polygon.
> I override shape, boundingRect and paint functions in it.
> I can see the polygons that i describe in the below QML code:
> 
> Code:
> import MyTypes 1.0
> import QtQuick 1.0
> import Qt 4.7
> 
> Item {
>     id: container
>     width: 350; height: 250
> 
>      Polygon {
>          id: aPolygon
>          x:0;y:0
>          width: 20; height: 20
>          name: "A simple polygon"
>          color: "blue"
>          vertices:[
> 
>          Point{x:20.0; y:80.0},
>          Point{x:20.0; y:20.0},
>          Point{x:80.0; y:80.0}
>          ]
> 
>          MouseArea{
>              anchors.fill: parent
>              drag.target: aPolygon
>              drag.axis: Drag.XandYAxis
>              drag.minimumX: 0
>              drag.maximumX: container.width - parent.width
>              drag.minimumY: 0
>              drag.maximumY: container.height - parent.width
>              onPressed:console.log("==============   ==onPressed")
> 
>          }
> 
> 
>      }
> 
> }
> 
> The problem is that MouseArea cares the x, y, width and height properties of 
> my polygon items, not the shape of my polygons.
> 
> 
> 
> 
> For example for first polygon onPressed work for the rectangle 
> x:0;y:0;width:20;height:20
> 
> 
> 
> How can i make MouseArea work for the polygon that vertices define.
> 
> 
> 
> I have overrided shape function, does not affect the result, what should i do 
> else?
> 
> 
> 
> Thanks
>                                               
> _______________________________________________
> Qt-qml mailing list
> [email protected]
> http://lists.qt.nokia.com/mailman/listinfo/qt-qml

_______________________________________________
Qt-qml mailing list
[email protected]
http://lists.qt.nokia.com/mailman/listinfo/qt-qml

Reply via email to