Removing the margins and border around QGraphicsRectItem?
-
In the following code, there are are margins around the rectangles and I am not sure what is causing them:
for (int i = 0; i < 7; i++) { QGraphicsRectItem* rectangle = new QGraphicsRectItem(0, 0, 50, 20); rectangle->setBrush(Qt::red); QGraphicsScene* scene = new QGraphicsScene; scene->addItem(rectangle); QGraphicsView* view = new QGraphicsView; view->setScene(scene); layout->addWidget(view, 0, i, 1, 1); }
Anyone know what the issue is? It looks like this:
http://i.imgur.com/lz3hIHr.png -
Hi,
the spaces between your QGraphicsViews are controlled by your layout. If you don't explicitly set the space width than it is inherited from its parent layout. You can set the spaces widths with:void QLayout::setSpacing(int)
. -
@Wieland Ah, I mean the white space (ie. the white square) around the red rectangle.
-
The white squares are the backgrounds of your 7 QGraphicsViews. Maybe your intention was to put all the 7 red rectangles in just a single QGraphicsView?