Results 1 to 9 of 9

Thread: QGraphicsView, OpenGL & rotated text

  1. #1
    Join Date
    Dec 2009
    Posts
    6
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default QGraphicsView, OpenGL & rotated text

    Hi,
    I use a QGraphicsView, and I want to put some OpenGL on it, so I set a QGLWidget as the view port. Then I add some text in the scene. The problem is, if I set any rotation on the text, the text looks ugly (see attachement 1), as if there were no antialiasing. Everything looks fine if I set a no OpenGL view port (see attachement 2). So I would like to know what I am doing wrong... I add a small code example.

    Qt Code:
    1. #include <QApplication>
    2. #include <QGraphicsView>
    3. #include <QGraphicsScene>
    4. #include <QGLWidget>
    5. #include <QLabel>
    6. #include <QGraphicsProxyWidget>
    7.  
    8. int main(int argc, char *argv[])
    9. {
    10. QApplication app(argc, argv);
    11.  
    12. QLabel* label = new QLabel("Example Text");
    13. label->setFont(QFont("Arial", 24));
    14.  
    15.  
    16. QGraphicsProxyWidget *proxy = scene.addWidget(label);
    17. proxy->rotate(2);
    18.  
    19. QGLWidget* viewport = new QGLWidget(QGLFormat(QGL::SampleBuffers));
    20.  
    21. view.setRenderHints(QPainter::Antialiasing
    22. | QPainter::SmoothPixmapTransform
    23. | QPainter::TextAntialiasing);
    24. view.setViewport(viewport);
    25. view.setGeometry(100, 100, 320, 60);
    26. view.setScene(&scene);
    27. view.show();
    28.  
    29. return app.exec();
    30. }
    To copy to clipboard, switch view to plain text mode 
    Attached Images Attached Images

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: QGraphicsView, OpenGL & rotated text

    Does your hardware and software support sample buffers? Try passing QPainter::HighQualityAntialiasing as a render hint, if your card supports fragment programs, it should make it use them for antialiasing.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  3. #3
    Join Date
    Dec 2009
    Posts
    6
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: QGraphicsView, OpenGL & rotated text

    Thanks for your reply. Unfortunatly, QPainter::HighQualityAntialiasing didn't help.
    How could I know if my hardware and software support sample buffer? My car is a decent Nvidia 8400gm and I use the 190.42 drivers on linux.

  4. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: QGraphicsView, OpenGL & rotated text

    You can use QGLContext::format() to query for the resulting format. Your card should be supporting sample buffers though.

    By the way, your code provides antialiased text on my system. It's not as pretty as without OpenGL of course but it is definitely antialiased.

    direct rendering: Yes
    OpenGL renderer string: GeForce 8400M GS/PCI/SSE2/3DNOW!
    OpenGL version string: 3.2.0 NVIDIA 190.32
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  5. #5
    Join Date
    Dec 2009
    Posts
    6
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: QGraphicsView, OpenGL & rotated text

    Interesting: If I open the NVIDIA X Server Settings configuration panel, and set Antialiasing > "override application settings", I get the antialiasing. If I set to "use application settings", then I loose it. There is something here. wysota, can you tell me which setting you use on your system please?

  6. #6
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: QGraphicsView, OpenGL & rotated text

    Defaults - "use application settings".
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  7. #7
    Join Date
    Dec 2009
    Posts
    6
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: QGraphicsView, OpenGL & rotated text

    There seems to be something wrong with my installation (debian sid), because it works fine on my ubuntu box. Maybe the drivers? (180.44 on ubuntu). I'll investigate a little bit more, and I'll let you know what I find.
    Anyway, thank you!

  8. #8
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: QGraphicsView, OpenGL & rotated text

    Check with glxinfo if you have direct rendering and all NVidia's extensions available.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  9. #9
    Join Date
    Dec 2009
    Posts
    6
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: QGraphicsView, OpenGL & rotated text

    So the problem was that I was using qt4.6 rc1 . Upgrading to 4.6 final fixed this...

Similar Threads

  1. Unhandled exception in qatomic
    By NewGuy in forum Qt Programming
    Replies: 14
    Last Post: 23rd July 2013, 09:49
  2. No text antialiasing with OpenGL graphicsview
    By pherthyl in forum Qt Programming
    Replies: 3
    Last Post: 13th March 2009, 22:47
  3. problem in rendering opengl on QGraphicsView
    By Sandip in forum Qt Programming
    Replies: 17
    Last Post: 15th April 2008, 08:27
  4. Replies: 3
    Last Post: 12th February 2008, 21:17
  5. Editable text in QGraphicsView
    By wysota in forum Qt Programming
    Replies: 8
    Last Post: 24th February 2007, 15:30

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.