После
painter->setRenderHint( QPainter::Antialiasing, true )
нет эффекта сглаживания! В чем может быть проблема?
Вот код:
#include <QtCore/QDebug>
#include <QtGui/QApplication>
#include <QtGui/QGraphicsItem>
#include <QtGui/QGraphicsScene>
#include <QtGui/QGraphicsView>
#include <QtOpenGL/QGLWidget>
class GraphicsItem : public QGraphicsItem
{
public:
GraphicsItem() : QGraphicsItem() {}
QRectF boundingRect() const
{
return QRectF( 0, 0, 100, 100 );
}
void paint( QPainter* painter, const QStyleOptionGraphicsItem*, QWidget* )
{
painter->setWorldMatrixEnabled( false );
painter->setRenderHint( QPainter::Antialiasing, true );
painter->drawLine( 0, 0, 80, 10 );
painter->setRenderHint( QPainter::Antialiasing, false );
painter->setWorldMatrixEnabled( true );
}
};
int main( int argc, char** argv )
{
QApplication app( argc, argv );
GraphicsItem* item = new GraphicsItem();
QGraphicsScene scene;
scene.addItem( item );
scene.setSceneRect( item->boundingRect() );
QGraphicsView view;
view.setViewport( new QGLWidget( &view ) );
view.setScene( &scene );
app.setActiveWindow( &view );
view.show();
view.resize( 300, 300 );
view.fitInView( scene.sceneRect() );
return app.exec();
}