PDA

View Full Version : Display antialiased rotated text or widget via QGraphicsScene



kiruahxh
27th April 2011, 17:25
Hello!

I have created a window that I make rotate by 0° to 45° via a QGraphicsScene.
The problem is that I've got a big "stair stepping" effect on the text.
I used QGraphicsView::setRenderHints(QPainter::SmoothPixm apTransform | QPainter::TextAntialiasing | QPainter::Antialiasing), but I'm not sure it really changes something, or the result is really bad.
Is it possible to have a good antialiasing in a QGraphicsScene?

Or, is it possible to rotate a widget and have it interact correctly with the mouse, and the keyboard?

MarekR22
27th April 2011, 17:48
I must say that something is broken in text rendering in Qt, when transformations are used. "stair stepping" is the less annoying problem.
I think I've seen bug report about this.

kiruahxh
28th April 2011, 09:25
Okay, thanks for your answer.
Any idea about what I could do?

I don't know if I can get both feel and look work for now, but at least I want to have a good looking interface.
On various posts, I've seen that you reimplement QPainter, but is it possible to store the original QPixmap rendered (without show it), modify it and then draw it to the screen?
Because I don't see the way to catch the pixmap

kiruahxh
28th April 2011, 15:35
I managed to enable the antialiasing without having the interaction (for people who have problems to do it : create the widget you want to turn, and a second widget. Instanciate the first widget, but do not show it. Then, when the second must be displayed, it asks the first to render (Qwidget::render(...)), it rotates the obtained pixmap and displays it.

I've got a big idea!
Do you think this could work ? :

1) Make a QGraphicsScene and a view for my widget
2) make the view or the proxy rotate to guarantee the interaction is correct
3) call 'render' on the widget to have the not-rotated pixmap
4) reimplement the view paintEvent to display the rotated antialiased pixmap

in fact, the graphicsScence would be the model, while we display it with a better looking. But I must have the model and the display exactly at the same position