OpenGL antialiasing problem



  • Hi fellow programers.
    I have a problem with antialiasing in a QOpenGLWidget dirived widget. In the paintEvent I have

     QPainter painter(this);
     painter.setRenderHints(QPainter::Antialiasing | QPainter::SmoothPixmapTransform | QPainter::TextAntialiasing);
    
    if(refreshAll)
    {
            QPixmap tmpP(width(), height());
            tmpP.fill(QColor(90,90,90));
            QPainter painter_tmp(&tmpP);
            painter_tmp.setRenderHints(QPainter::Antialiasing | QPainter::SmoothPixmapTransform | QPainter::TextAntialiasing);
    
          //Some drawing here
    ....
           BackGroundMapP = tmpP.copy(0,0,tmpP.width(), tmpP.height()); //BackGroundMapP is s Pixmap
            refreshAll= false;
    }
    painter.drawPixmap(0,0,BackGroundMapP);
    
    //Some more drawing here
    .....
    
    qDebug() << painter.renderHints(); // This is showing that the flags are set OK.
    

    But the result is without Antialiasing or Text Antialiasing for everything drawn by painter. If I test to see if the flags are set correctly I get that they are. All drawn with painter_tmp is Antialiased though!! So what could be the problem? Apparently there are no driver problems, as everything drawn with painter_tmp is working fine.


  • Lifetime Qt Champion

    Hi,

    What version of Qt ? On what OS ?



  • Hi,
    It is happening with Qt 5.4.1 on Windows 7 and on Qt 5.6.1 on Windows 10.



  • @Xumepoc

    Hi.

    Have you set the surface format for the widget or app.?



  • Well I set the attribute for the app

    a.setAttribute(Qt::AA_UseDesktopOpenGL);
    

    Do I have to set the QSurfaceFormat for the widget too?



  • @Xumepoc

    Of course you need to set the surface format for the widget or app.
    A.setAttribute (Qt :: AA_UseDesktopOpenGL) has nothing to do with this problem.



  • Yep :D :D you were completely right. Set it to sample 10 and everything is crisp and smooth. Thank you very much.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.