Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Antialiasing does not work with QGraphicsView
Qt 6.11 is out! See what's new in the release blog

Antialiasing does not work with QGraphicsView

Scheduled Pinned Locked Moved General and Desktop
2 Posts 1 Posters 2.6k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • N Offline
    N Offline
    nvchrisn
    wrote on last edited by
    #1

    I have a simple application using Qt 5.0.1, it looks like:

    @

    MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow)
    {
    ui->setupUi(this);
    m_Settings = new QSettings();

    // Create the tab widget to hold all the editable documents in the center
    

    /*
    setTabPosition( Qt::AllDockWidgetAreas, QTabWidget::North );

    // Recent file action
    for (int i = 0; i < MaxRecentFiles; ++i) {
    m_RecentFileActions[i] = new QAction(this);
    m_RecentFileActions[i]->setVisible(false);
    connect(m_RecentFileActions[i], SIGNAL(triggered()),
    this, SLOT(openRecentFile()));
    }

    // Recent file menu
    QMenu fileMenu = ui->menuFile;
    m_SeparatorAction = fileMenu->addSeparator();
    for (int i = 0; i < MaxRecentFiles; ++i)
    fileMenu->addAction(m_RecentFileActions[i]);
    updateRecentFileActions();
    /
    QGraphicsView
    view = new QGraphicsView( this );
    view->setRenderHint( QPainter::HighQualityAntialiasing, true );
    this->setCentralWidget( view );
    view->setScene( new QGraphicsScene() );
    QGraphicsScene
    theScene( view->scene() );
    theScene->setSceneRect( -200, -200, 400, 400 );
    QGraphicsLineItem* newItem = new QGraphicsLineItem();
    theScene->addItem( newItem );
    newItem->setLine( -50, -50, 30, 50 );
    }

    MainWindow::~MainWindow()
    {
    delete ui;
    }
    @

    The line renders extremely ugly and aliased. Why is this?

    Chris

    1 Reply Last reply
    0
    • N Offline
      N Offline
      nvchrisn
      wrote on last edited by
      #2

      This would have fixed it:

      @
      view->setRenderHints( QPainter::Antialiasing | QPainter::HighQualityAntialiasing );
      @

      It appears that asking for high quality antialiasing doesn't imply that you want antialiasing which is kind of odd but it works and is really nice now.

      1 Reply Last reply
      0

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved