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. QWidget in QScrollArea not repainting as expected
Forum Update on Monday, May 27th 2025

QWidget in QScrollArea not repainting as expected

Scheduled Pinned Locked Moved General and Desktop
2 Posts 1 Posters 682 Views
  • 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.
  • K Offline
    K Offline
    kloveridge
    wrote on last edited by
    #1

    I have a QScrollArea that contains a custom QWidget. I am finding if I scroll the window slowly, it draws as expected. But if I really scroll fast and bump the extents of the window, its as though the painting got caught off guard and did a "double exposure" of the content.

    If I had to take a guess of whats happening, I would guess the paintEvent() is not getting the message to repaint once the window has settled down. Any thoughts on this?

    1 Reply Last reply
    0
    • K Offline
      K Offline
      kloveridge
      wrote on last edited by
      #2

      I figured it out. I was doing this to set up the code:
      @ // HIERARCHY VIEW
      m_hierWindow = new HierWidget(this);
      //m_hierWindow->setBackgroundRole(QPalette::Base);
      m_hierWindow->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
      m_hierWindow->setMinimumHeight(100);
      m_hierWindow->setMinimumWidth(500);

      // SETUP MAIN WINDOW
      m_scroller = new QScrollArea(this);
      m_scroller->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOn);
      m_scroller->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOn);
      m_scroller->setWidget(m_hierWindow);@

      I shouldn't have been setting the HierWidget parent. So here is what works:

      @ // HIERARCHY VIEW
      m_hierWindow = new HierWidget();
      //m_hierWindow->setBackgroundRole(QPalette::Base);
      m_hierWindow->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
      m_hierWindow->setMinimumHeight(100);
      m_hierWindow->setMinimumWidth(500);

      // SETUP MAIN WINDOW
      m_scroller = new QScrollArea(this);
      m_scroller->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOn);
      m_scroller->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOn);
      m_scroller->setWidget(m_hierWindow);

      ui->TreeView->addWidget(m_scroller);
      ui->ModelView->addWidget(m_model);
      @

      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