If your not subclassing QLabel, and instead only using QLabel, then use the following :
{
switch(eve->type())
{
{
return handlePaintEvent(obj, eve);
}
default:
{
return QObject::eventFilter(obj, eve
);
}
}
} // eventFilter
{
QPainter painter
(static_cast<QWidget
*>
(obj
));
//here u may check if obj is your ui.frame() ......
}
bool myView::eventFilter(QObject *obj, QEvent *eve)
{
switch(eve->type())
{
case QEvent::Paint:
{
return handlePaintEvent(obj, eve);
}
default:
{
return QObject::eventFilter(obj, eve);
}
}
} // eventFilter
bool myView::handlePaintEvent(QObject *obj, QEvent *eve)
{
QPainter painter(static_cast<QWidget *>(obj)); //here u may check if obj is your ui.frame()
......
}
To copy to clipboard, switch view to plain text mode
But if you are subclassing QLabel, better override its paintEvent() and initialize a painter like :
{
.......
}
void myLabel::paintEvent ( QPaintEvent * event )
{
QPainter painter(this);
.......
}
To copy to clipboard, switch view to plain text mode
Bookmarks