[Qt-interest] QGraphicItem rotate problem
Sean Harmer
sean.harmer at maps-technology.com
Mon Sep 28 16:55:38 CEST 2009
Hi,
On Monday 28 Sep 2009 14:18:50 Riccardo Roasio wrote:
> Hi,
>
> I need to rotate a QGraphicItem and make a union between its QPolygon
> and another QGraphicItem QPolygon in this way:
>
> QString Table::attachBrother(Table *b)
> {
> int i;
>
> int my_x=this->x();
> int my_y=this->y();
> int brother_x=b->x();
> int brother_y=b->y();
>
> int x_diff=brother_x-my_x;
> int y_diff=brother_y-my_y;
>
> attached_brothers<<b;
>
>
> QPolygon polygon=b->getTablePolygon();
>
> polygon.translate(x_diff,y_diff);
>
>
> table_polygon=table_polygon.united(polygon);
> std::cout << "Brother attached" << std::endl;
> update();
>
> ....
>
>
> If both objects have 0 degrees of rotation all is ok, but if i rotate
> one or both of them so the union result in strange stuff.
> I think is because rotating aa QGraphicItem mantains the original
> points,so if one point is at -10,-10 and another is at -10,-20 after
> the rotation they are in the same positions so this cause
> preoblems....
>
> There is a way to rotate also these points?
>From the docs:
"QPointF QGraphicsItem::mapToScene ( const QPointF & point ) const
Maps the point point, which is in this item's coordinate system, to the
scene's coordinate system, and returns the mapped coordinate."
I think this sounds like what you need.
Cheers,
Sean
More information about the Qt-interest-old
mailing list