PDA

View Full Version : how to enable borders in QGraphicsScene?



as001622
24th May 2008, 14:50
Hello!
I have a window with couples of regular widgets and some of my own graphics widgets. I join my graphic items to QGraphicScene, then add it to QGraphicsView and then add it to QLayout. After this I can see a thin border around this scene. How to enable this border? Because I have a black backround of my window and all my widgets are black, so this border looks not so nice.

patrik08
24th May 2008, 16:42
If you like print border from QGraphicsScene draw a QGraphicsLineItem


to not print drawBackground on view....



void GraphicsView::drawBackground(QPainter *painter, const QRectF &rect)
{
setCacheMode(CacheNone); /* cache or not Background QGraphicsView::CacheBackground*/

painter->save();
painter->setPen( QPen(Qt::darkGray,1) );
painter->setBrush(QBrush(chessgrid));
painter->drawRect(scene->sceneRect());
painter->restore();

}

as001622
24th May 2008, 18:01
Unfortently, this couldn't solve my problem, but thanks in anyway!

aamer4yu
24th May 2008, 18:41
can u show the problem in a snapshot ??

also try some setSpacing() or setMargin() functions... may be they will help to remove the border

as001622
25th May 2008, 10:08
Here is part of my program interface, I can't show it, so it's just to let you now what the problem I have.
http://i011.radikal.ru/0805/80/e7c3551c1367.jpg
On top you can see a thin line around some shape, so this line is showing arond my QGraphicsView, I wanna to enable this line. I've tryed also setSpacing() and set Margin but it couldn't help. I think that problem is in how QLayout add QGraphicsView in layout, why this line is showing?

durbrak
25th May 2008, 11:38
QGraphicsView is a sub-class of QFrame. There you have setFrameShadow() and a few others.

aamer4yu
25th May 2008, 15:45
try to set setFlat() on graphicsView...
hope it helps

as001622
26th May 2008, 07:57
setFrameShadow(QFrame::Raised) solved my problem. Thanks!

FireMan
3rd June 2008, 19:43
I have been stumbling to find the solution to the problem that is opposite to the original issue in this thread -- I want to get rid off the border a the border of the view (I think it's also the border of the view, not border of the scene, as in this thread). Thanks to the information here, I got the solution: setFrameStyle(QFrame::NoFrame);