QGraphicsLineItem line is not at the center of the item
I am drawing a QGraphicsLineItem line at the middle of the scene in QGraphicsView .But the lines doesn't appear at the (0,0) It has an offset of 5 pixels from the center on X axis.How do I align the line to be at it's bounds center?
Here is my code:
QGraphicsLineItem *scrubber = new QGraphicsLineItem(0,0,0,100);
a) x=0 is not in the center of the graphics scene's sceneRect. You may e.g. have an additional horizontal line from x=-5 to x=15 units.
b) the graphics scene is not displayed in the center of the graphics view.
c) the graphics view is displayed with a margin.
Thanks.But how do I check these things?
First, check the QGraphicsView's alignment property.
Then, read the sceneRect of the QGraphicsScene. If you only added the one line, it should be exactly big enough to hold that line.