PDA

View Full Version : How to update eventFilter function?



newermind
30th April 2009, 08:44
How to update eventFilter function?

I use update( ) function but it`s not worked .

bool CLASS_NAME::eventFilter(QObject *o, QEvent *e)
{
for ( int i = 0; i < 42; i++ ) {

if (o == tree_widget[i]->viewport() && e->type() == QEvent::Paint) {

QPainter p;

p.begin(tree_widget[i]->viewport() );

p.drawText( 35, 70, "something");

p.end();
}
}

return QWidget::eventFilter(o, e);
}

e8johan
30th April 2009, 09:27
You cannot paint outside the paintEvent method. That is one of the key rules of Qt widgets. What is it that you are trying to achieve? It looks as if you should sub-class the QTreeWidget, reimplement paintEvent and then call the QTreeWidget's paintEvent function at the end.

newermind
30th April 2009, 09:36
I can paint using eventFilter. But it`s worked when program started.

I try to achive; when clicked button, draw differrent text.