Graphics classes troubles…
1. I have an inherited class QGraphicsView and implemented paintEvent, why does debugger write: QPainter::begin: Paint device returned engine == 0, type: 1 ??
This is whole code:
- {
- painter.drawRect(this->sceneRect());
- }
And I am not drawing outside from paintEvent method.
2. Why I have scollbars in my GraphicsView window ? How to remove them?
13 replies
2. Why I have scollbars in my GraphicsView window ? How to remove them?
QGraphicsView [doc.qt.nokia.com] inherits QAbstractScrollArea [doc.qt.nokia.com] so you can permanently disable the scrollbars by calling the following methods (please note the arguments):
Best regards,
Leon
Thanks, and my first problem? What do you think?
Honestly I did not understand what exactly is the problem. Btw what are you trying to achieve?
If you want just to set a background color it would be easier to use:
- setStyleSheet("background-color:rgb(255,127,0);");
QGraphicsView inherits QAbstractScrollArea, which inherits QFrame, which inherits QWidget so you should be able to call setStyleSheet :)
Cheers,
Leon
Please check this thread at stackoverflow [stackoverflow.com] the proposed solution is to use viewport() [doc.qt.nokia.com] instead of this:
Best regards,
Leon
You can also reimplement QGraphicsScene::drawBackground [doc.qt.nokia.com]
or take a look also at backgroundBrush [doc.qt.nokia.com]
regards
You must log in to post a reply. Not a member yet? Register here!





