Hi,
I am new to QT programming (but I really like it :-)) and here is an issue I do not know how to solve:
I would like to be able to switch the renderHint QPainter::SmotthPixmapTransform on and off dynamically.
My custom QGraphicsItem looks like
{
public:
MyItem()
{
}
{
if(mouseaction_going_on)
painter
->setRenderHint
(QPainter::SmoothPixmapTransform,
false);
else
painter
->setRenderHint
(QPainter::SmoothPixmapTransform,
true);
}
}
class MyItem : public QGraphicsItem
{
public:
MyItem()
{
QGraphicsLineItem * top = new QGraphicsLineItem(...,this);
QGraphicsLineItem * left = new QGraphicsLineItem(...,this);
QGraphicsPixmapItem * pix = new QGraphicsPixmapItem(...,this);
}
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
{
if(mouseaction_going_on)
painter->setRenderHint(QPainter::SmoothPixmapTransform, false);
else
painter->setRenderHint(QPainter::SmoothPixmapTransform, true);
}
}
To copy to clipboard, switch view to plain text mode
But in practice, nothing happens, the rendering is performed with exactly those renderHints that have been specified at creation time of the QGraphicsView.
What about the painter->save() and restore() functions? Might they help me?
By the way, at whcih stage of the painting procedure is the painting of the child items of MyItem perfomed? Maybe the painting of them is already done when it comes to my setRenderHints()-calls.
Thank you very much in advance for your great support!!!
Best Regards,
Oliver
Bookmarks