Nominate our 2022 Qt Champions!

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

    I have this results (ok for me)

    but when I scroll, I have this horrible results:

    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