QWidget in QScrollArea not repainting as expected



  • 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?



  • 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);
    @


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.