yogeshupreti
19th December 2012, 16:00
Dear All,
I have Antialiasing problem with the rotated text in QGraphicsView. I have found some bugs regarding the same problem and I have tried the latest Qt Version (5.0.0 RC2), but the problem is still not Fixed. Does someone know a workaround?
I have the following code:
class FieldBoundText : public QGraphicsTextItem
{
Q_OBJECT
public:
/*!
Class initializer,
- str: supply a string to display
*/
FieldBoundText(QString str, QGraphicsItem * parent = 0);
and have re-implemented the paint function for the class to add Anti-Aliasing:
protected:
/*!
Reimplementing painter class for Antialiasing the font
*/
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);
Which looks like:
void FieldBoundText::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget){
painter->setRenderHints(QPainter::Antialiasing|QPainter::Te xtAntialiasing);
QGraphicsTextItem::paint(painter,option,widget);
}
Implementing the code like:
FieldBoundText *txt = new FieldBoundText(QString("%1").arg(corner));
txt->setPos(xStart,0);
txt->setRotation(-45.0);
Results in the text without Anti-aliasing :
8514
Please let me know if there is some work around for this problem?
- Yogesh Upreti
I have Antialiasing problem with the rotated text in QGraphicsView. I have found some bugs regarding the same problem and I have tried the latest Qt Version (5.0.0 RC2), but the problem is still not Fixed. Does someone know a workaround?
I have the following code:
class FieldBoundText : public QGraphicsTextItem
{
Q_OBJECT
public:
/*!
Class initializer,
- str: supply a string to display
*/
FieldBoundText(QString str, QGraphicsItem * parent = 0);
and have re-implemented the paint function for the class to add Anti-Aliasing:
protected:
/*!
Reimplementing painter class for Antialiasing the font
*/
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);
Which looks like:
void FieldBoundText::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget){
painter->setRenderHints(QPainter::Antialiasing|QPainter::Te xtAntialiasing);
QGraphicsTextItem::paint(painter,option,widget);
}
Implementing the code like:
FieldBoundText *txt = new FieldBoundText(QString("%1").arg(corner));
txt->setPos(xStart,0);
txt->setRotation(-45.0);
Results in the text without Anti-aliasing :
8514
Please let me know if there is some work around for this problem?
- Yogesh Upreti