PDA

View Full Version : matrix for QBrush



navi1084
4th February 2010, 11:06
Hi,
I am creating re-sizable nodes(QFraphicsItem) for some shapes(QgraphicsItem). While zooming i doesn't want nodes to be zoomed in shapes but the node's co-transformation should be applied. I have read the comment in http://www.qtcentre.org/threads/1395...hics-view-item, where i can resolve this by apllying the inverted matrix of painter instance to QBrush instance. but in my program brush matrix is not combined with painter instance. I am using Qt 4.4. Is this is a bug.

http://www.qtcentre.org/threads/13950-Not-Scaling-QBrush-style-fro-qgraphics-view-item

Thanks

JohannesMunk
4th February 2010, 16:38
It would help if you provided some source code of your painting. Or are we supposed to guess, what went wrong?

navi1084
5th February 2010, 05:26
Please find the attachment. i have attached the whole project and the snapshot of problem. I have developed using QT 4.4 and VS 20084246

JohannesMunk
5th February 2010, 10:59
The brush-matrix affects stuff like the stippling pattern of the brush. But it can't affect the polygon-coordinates of your handles, which are transformed by the painters scaling..

I would approach your problem from a different angle:

Make your CHandleItem a QGraphicsItem subclass. (Not a QGraphicsPolygonItem whose polygon features you are not even using..).

Use setFlag(QGraphicsItem::ItemIgnoresTransformations, true);
That will transform the items coordinates right, but won't scale or shear it.

In your updateHandle() method, specify the Position of the handles, and do the actual drawing of the 5x5 handle in the paint method.

HIH

Johannes

navi1084
5th February 2010, 11:20
Thanks for the reply. I will implement ur suggestion and let you know.

JohannesMunk
5th February 2010, 11:27
Allright! Make sure you specify the item's position through QGraphicsItem::setPos, so that the QGraphicsScene can do its magic.

In the paint method you then just need to draw a rectangle of your handlesize around the items center: 0/0.

Johannes