Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. How do I stop repainting on scroll
Forum Updated to NodeBB v4.3 + New Features

How do I stop repainting on scroll

Scheduled Pinned Locked Moved Unsolved General and Desktop
4 Posts 2 Posters 570 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • L Offline
    L Offline
    lansing
    wrote on last edited by
    #1

    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.

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      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 ?

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      L 1 Reply Last reply
      0
      • SGaistS SGaist

        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 ?

        L Offline
        L Offline
        lansing
        wrote on last edited by
        #3

        @SGaist

        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.

        1 Reply Last reply
        0
        • SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on last edited by
          #4

          One thing you can check is the QGraphicsView update mode.

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          1 Reply Last reply
          0

          • Login

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • Users
          • Groups
          • Search
          • Get Qt Extensions
          • Unsolved