QTableView background problem



  • Hi,

    I would like to draw a pixmap on bottom right corner of a QTableView.
    For that I overrided the panit event function:

    void MdTextureTableView::paintEvent(QPaintEvent* event)
    {
        if(!m_pixBackground.isNull())
        {
            QPainter painter(viewport());
            int iHeight = viewport()->height() / 1.5;
            int iWidth = (m_pixBackground.size().width() / m_pixBackground.size().height()) * iHeight;
            painter.drawPixmap(viewport()->width() - iWidth, viewport()->height() - iHeight, iWidth,iHeight, m_pixBackground);
            painter.end();
        }
        QTableView::paintEvent(event);
    }
    

    I have this results (ok for me)
    0_1505899974946_c17eae32-3948-44ea-a9aa-07d1c3886702-image.png

    but when I scroll, I have this horrible results:
    0_1505900053787_81c2891f-e39a-4246-9813-3ece1dfa8f0f-image.png

    I don't know what I missed, how can I fix this ?
    Even this does not change anything:

    QObject::connect(horizontalScrollBar(), SIGNAL(valueChanged(int)), this, SLOT(repaint()));
    

    More information:
    (I set a QStyledItemDelegate to display elements)



  • QObject::connect(horizontalScrollBar(), SIGNAL(valueChanged(int)), this->viewport(), SLOT(update()));


Log in to reply
 

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