GraphicsView paintEvent question
Dear All , I have created a CustomLabel class which is based QLabel, then I added this label to QGraphicsView via QGraphicsProxyWidget.
Code:
CustomLabel *imageItem = new CustomLabel();
imageItem->setSelectionStatus(true);
imageItem->setImagePath("/home/can/workspace/DenemeGraphic/media/home.png");
QGraphicsProxyWidget *pCImageProxyWidgetInstance = new QGraphicsProxyWidget(0, Qt::Window);
pCImageProxyWidgetInstance->setWidget(imageItem);
pCImageProxyWidgetInstance
->setCacheMode
( QGraphicsItem::NoCache );
pCImageProxyWidgetInstance->setPos(100,100);
scene->addItem(pCImageProxyWidgetInstance);
In CustomLabel I writed a paintEvent(QPaintEvent *pe) function, the problem is , always it is refreshing , There is a printf() in painEvent and it is continiously printing string.
Re: GraphicsView paintEvent question
Setting
Quote:
pCImageProxyWidgetInstance->setCacheMode ( QGraphicsItem::NoCache );
Could cause a continues refreshing. Try other cache modes.
And please show us the paintEvent.
Re: GraphicsView paintEvent question
Code:
QPixmap CustomLabel
::PreparePixmap() {
pixmap.load(m_ImagePath);
pixmap = pixmap.scaled(WIDTH,HEIGHT,Qt::IgnoreAspectRatio,Qt::FastTransformation);
printf("a\n");
return pixmap;
}
{
setPixmap(pixmap);
if(m_Selected)
{
pen.setWidth(5);
painter.setPen(pen);
painter.drawPixmap(3,3,pixmap);
painter.drawRect(0,0,width()-1,height()-1);
}
}
it is continously printing "a".
Re: GraphicsView paintEvent question
What printf doing here ?
Can you please comment the printf statement for a while. use qDebug instead.
Re: GraphicsView paintEvent question
I changed it , but it is same, still printing
Re: GraphicsView paintEvent question
Quote:
Originally Posted by
anafor2004
it is continously printing "a".
Where is it printing ?
On my machine its running well, a red colored boundary with a pixmap is displaying with no refreshing problem.