Results 1 to 8 of 8

Thread: Problems with drawing image in paintEvent of QTreeView

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Tito Serenti Guest

    Default Problems with drawing image in paintEvent of QTreeView

    Hi, I'm trying to put a background image in a QTreeView, but I can't use styles because the image needs to be loaded from a QByteArray. I've implemented this paint event, and the image gets drawn, but when I scroll the tree view, it doesn't re-draw the image. It just scrolls off the view and disappears. When I click inside the tree view or re-size, it gets re-drawn where it's supposed to be. Any ideas on how I can make the tree view redraw the image while scrolling? Thank you in advance!

    Qt Code:
    1. void TreeView::paintEvent(QPaintEvent *event)
    2. {
    3. QPainter painter(viewport());
    4. painter.drawImage(imageLeftMargin, imageTopMargin, image);
    5. painter.end();
    6. QTreeView::paintEvent(event);
    7. event->accept();
    8. };
    To copy to clipboard, switch view to plain text mode 
    Last edited by jpn; 24th December 2008 at 11:20. Reason: missing [code] tags

Similar Threads

  1. Problems with QString
    By cyberboy in forum Qt Programming
    Replies: 2
    Last Post: 13th October 2008, 08:18
  2. background image in QTreeView
    By momesana in forum Qt Programming
    Replies: 2
    Last Post: 11th January 2007, 06:25

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.