hheld
2nd January 2011, 15:48
To experiment a little with QGraphicsView, I wanted to implement a plot widget that plots 2D data points, connecting consecutive points by a line. Both horizontal and vertical scrollbars are set to be always off.
First test was a plot of a sine function, discretized into 50 equidistant data points on the interval [0, 2*pi]. That yields a y-range of [-0.999486, +0.999486]. The underlying SceneRect's size is set to exactly these width and height, resp. Therefore, I expected the plot to reach all the way to the QGraphicsView's boundary, essentially touching its edges. However, and this is what my question is about: there is always a margin of maybe 1 or 2 pixels. Where does this margin come from, and how can it be removed? What else could I have missed and done wrong?
Attached you find two images of the plot. In the first one ('plot_centered.jpg'), the QGraphicsView is aligned horizontally and vertically centered, and the margin is clearly visible on each edge. In the other one ('plot_leftTop.jpg'), it is aligned to the "left and top". The result is that the plot starts exactly at the left and top edge, but the gap next to the other 2 edges is accordingly bigger.
Not sure if it's important, but I'm using Qt 4.7.0 on Linux. Any help or hints are greatly appreciated!
First test was a plot of a sine function, discretized into 50 equidistant data points on the interval [0, 2*pi]. That yields a y-range of [-0.999486, +0.999486]. The underlying SceneRect's size is set to exactly these width and height, resp. Therefore, I expected the plot to reach all the way to the QGraphicsView's boundary, essentially touching its edges. However, and this is what my question is about: there is always a margin of maybe 1 or 2 pixels. Where does this margin come from, and how can it be removed? What else could I have missed and done wrong?
Attached you find two images of the plot. In the first one ('plot_centered.jpg'), the QGraphicsView is aligned horizontally and vertically centered, and the margin is clearly visible on each edge. In the other one ('plot_leftTop.jpg'), it is aligned to the "left and top". The result is that the plot starts exactly at the left and top edge, but the gap next to the other 2 edges is accordingly bigger.
Not sure if it's important, but I'm using Qt 4.7.0 on Linux. Any help or hints are greatly appreciated!