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. QTableView background problem
Qt 6.11 is out! See what's new in the release blog

QTableView background problem

Scheduled Pinned Locked Moved Solved General and Desktop
2 Posts 1 Posters 1.0k 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.
  • Roy44R Offline
    Roy44R Offline
    Roy44
    wrote on last edited by
    #1

    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)

    1 Reply Last reply
    0
    • Roy44R Offline
      Roy44R Offline
      Roy44
      wrote on last edited by
      #2

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

      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