On Fri, January 23, 2009 1:20 pm, Michael Quigley wrote:
> How would I go about making QGraphicsLineItem's bounding rectangle
> implementation deal with the extra area that can extend outside of the
> line's bounding rectangle when an arrowhead is present on the end of the
> line?
>
> This is where remedial trig assistance would be useful. ;-)

I found my error. I had been doing:

----8<----

                removeFromIndex();
                sourcePoint.setX(sourceNode.pos().x() - sourcePaddingX);
                sourcePoint.setY(sourceNode.pos().y() - sourcePaddingY);

                destinationPoint.setX(destinationNode.pos().x() + 
destinationPaddingX);
                destinationPoint.setY(destinationNode.pos().y() + 
destinationPaddingY);

                boundingRect.setBottomLeft(sourceNode.pos());
                boundingRect.setTopRight(destinationNode.pos());

                /** WRONG **/

                boundingRect.adjust(-extra, -extra, extra, extra);
                boundingRect = boundingRect.normalized();

                /** /WRONG **/

                addToIndex();

----8<----

When I should have been doing:

                boundingRect = boundingRect.normalized();
                boundingRect.adjust(-extra, -extra, extra, extra);

Oops! With that fixed, everything seems good now!

One last question... I can't seem to find "QGraphicsItem.addToIndex()" and
"QGraphicsItem.removeFromIndex()" in the documentation. What exactly are
these doing in this context? My suspicion is that calling
"removeFromIndex()" and then "addToIndex()" is doing something similar to
calling "update()"?

Thanks so much for all the help!

Michael

_______________________________________________
Qt-jambi-interest mailing list
Qt-jambi-interest@trolltech.com
http://lists.trolltech.com/mailman/listinfo/qt-jambi-interest

Reply via email to