How do I stop repainting on scroll
Unsolved
General and Desktop
-
I have created a scrolling area with QGraphicsView and QGraphicsItem, where the Qgraphicsitem is bigger than the view, thus creating a scrolling bar. However when I clicked and moved the scroll bar, the scene kept repainting itself. How do I stop these unnecessary repaints? It's eat up my cpu resource for no reason.
-
Hi,
Can you show how you setup your scene/view ?
By the way:
What version of Qt are you using ?
What os are you running ? -
I'm using Qt 5.13.2 and Windows 10.
In my ui file, I created a graphicsView object.mainwindow.cpp
scene = new QGraphicsScene(this); myItem = new CustomerGraphicsItem(); scene->addItem(myItem ) ui->graphicsView->setScene(scene)
mycustomeitem.cpp
void CustomerGraphicsItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) { QBrush blackBrush(Qt::black); painter->fillRect(boundingRect(), blackBrush); painter->drawText(blah blah blah) qDebug() << "printing..."; }
The program redraw every time I move the scroll bar or resize my window.
-
One thing you can check is the QGraphicsView update mode.