PDA

View Full Version : QWidget::paintEvent - when is it called and what region does it update?



slscripters
29th April 2010, 05:44
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,



void QCustomDialog::paintEvent(QPaintEvent * paintEvt)
{
QPainter painter(this);

// draw title bar here

if(changeColorOfUpArrow == true)
{
qDebug("black");
painter.setBrush(QBrush(Qt::black, Qt::SolidPattern));
}
else
{
qDebug("red");
painter.setBrush(QBrush(Qt::red, Qt::SolidPattern));
}

// draw up arrow here
}


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? :confused::(