Results 1 to 1 of 1

Thread: QWidget::paintEvent - when is it called and what region does it update?

  1. #1
    Join Date
    Apr 2010
    Location
    Bahamas
    Posts
    29
    Thanks
    3
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11

    Default QWidget::paintEvent - when is it called and what region does it update?

    I've subclassed QDialog and reimplemented the paintEvent function. I've noticed that paintEvent does not update the regions i want to redraw. My custom dialog contains a QListWidget (list) by the way.

    My code goes like this,

    Qt Code:
    1. void QCustomDialog::paintEvent(QPaintEvent * paintEvt)
    2. {
    3. QPainter painter(this);
    4.  
    5. // draw title bar here
    6.  
    7. if(changeColorOfUpArrow == true)
    8. {
    9. qDebug("black");
    10. painter.setBrush(QBrush(Qt::black, Qt::SolidPattern));
    11. }
    12. else
    13. {
    14. qDebug("red");
    15. painter.setBrush(QBrush(Qt::red, Qt::SolidPattern));
    16. }
    17.  
    18. // draw up arrow here
    19. }
    To copy to clipboard, switch view to plain text mode 

    I have initially set the brush color to black. The if and else statements are executed correctly, I've verified this already. But the arrow drawn is always black even if control goes to the else statement. Does anybody know what I made wrong here or is this a known issue?
    Last edited by slscripters; 29th April 2010 at 06:54.

Similar Threads

  1. Newbie-Question: update does not trigger paintEvent
    By janitor in forum Qt Programming
    Replies: 5
    Last Post: 24th January 2013, 18:59
  2. paintEvent not getting called with QMainWindow
    By DiamonDogX in forum Qt Programming
    Replies: 12
    Last Post: 15th June 2011, 23:23
  3. Paintevent and update
    By csvivek in forum Qt Programming
    Replies: 1
    Last Post: 25th March 2008, 08:09
  4. QWidget::resizeEvent is not called
    By maximAL in forum Qt Programming
    Replies: 9
    Last Post: 3rd February 2008, 17:41
  5. Calling update() from paintEvent()
    By wonder.mice in forum Qt Programming
    Replies: 8
    Last Post: 11th January 2008, 14:41

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
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.