Hello,
is it possibile to specify a per-item antialias rendering in a QGraphicsView? As far as I understand QGraphicsView::setRenderHint affects all of the items, but in my application some items would look nicer without aliasing.
Thanks
Hello,
is it possibile to specify a per-item antialias rendering in a QGraphicsView? As far as I understand QGraphicsView::setRenderHint affects all of the items, but in my application some items would look nicer without aliasing.
Thanks
You can use / not use aliasing in the QGraphicsItem::paint itself,, cant you ?
mattc (3rd May 2009)
If you don't want to do all the drawings yourself, subclass you needed item and adjust the flags:
Qt Code:
void MyGraphicsItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) { painter->setRenderHint(painter->renderHint() /*...*/); YourBaseClass::paint(painter, option, widget); }To copy to clipboard, switch view to plain text mode
mattc (3rd May 2009)
Hello aamer4yu,
somehow such a simple solution didn't cross my mind! Here is the working code:
Qt Code:
void MyGraphicItem::paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget) { }To copy to clipboard, switch view to plain text mode
Thank you very much.
thanks Lykurg,
I've seen your reply after posting. I removed the line restoring the painter state, and changed the first line to preserve existing render hints.
Qt Code:
void MyGraphicItem::paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget) { }To copy to clipboard, switch view to plain text mode
Btw, browsing the docs I found some inconsistency about the render hints functions. From QPainter:
so, what is setRenderHint*s*() supposed to do? Also, no "renderHint()" in QPainter.The renderHints() function returns a flag that specifies the rendering hints that are set for this painter. Use the setRenderHint() function to set or clear the currently set RenderHints
Yeah, I was mixing up some things. It's:orQt Code:
To copy to clipboard, switch view to plain text modewith hints g.e. "QPainter::Antialiasing|QPainter::TextAntialiasing ".Qt Code:
To copy to clipboard, switch view to plain text mode
Bookmarks