Results 1 to 2 of 2

Thread: Cosmetic pen with opengl rendering

  1. #1
    Join Date
    Jun 2010
    Posts
    1
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Cosmetic pen with opengl rendering

    Hi all,
    I try to set the cosmetic pen for QGraphicsPolygonItem but if I use the opengl render it doesn't work as I expect.
    Here the code:

    Qt Code:
    1. scene.setSceneRect(-0.0005,-0.0005,0.001,0.001);
    2.  
    3. QPen pen;
    4. pen.setColor(QColor(Qt::red));
    5. pen.setCosmetic(true);
    6.  
    7. QPolygonF polyF;
    8. polyF << QPointF(0.0002,0.0002)
    9. << QPointF(0.0003,0.0002)
    10. << QPointF(0.0003,0.0003)
    11. << QPointF(0.0002,0.0003);
    12.  
    13.  
    14. polyItem->setPen(pen);
    15.  
    16. scene.addItem(polyItem);
    17.  
    18. ui->graphicsView->setBackgroundBrush(Qt::black);
    19. ui->graphicsView->setCacheMode(QGraphicsView::CacheBackground);
    20. ui->graphicsView->setRenderHint(QPainter::Antialiasing);
    21. ui->graphicsView->setViewport(new QGLWidget(QGLFormat(QGL::SampleBuffers)));
    22. ui->graphicsView->setScene(&scene);
    To copy to clipboard, switch view to plain text mode 

    if I comment out the following code line it works fine.
    Qt Code:
    1. ui->graphicsView->setViewport(new QGLWidget(QGLFormat(QGL::SampleBuffers)));
    To copy to clipboard, switch view to plain text mode 

    Thanks,
    Giuseppe

  2. #2
    Join Date
    Oct 2009
    Posts
    151
    Thanks
    6
    Thanked 13 Times in 11 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Cosmetic pen with opengl rendering

    Detailed Description

    The QGLWidget class is a widget for rendering OpenGL graphics.

    QGLWidget provides functionality for displaying OpenGL graphics integrated into a Qt application. It is very simple to use. You inherit from it and use the subclass like any other QWidget, except that you have the choice between using QPainter and standard OpenGL rendering commands.
    Note the inherit bit.
    Got to keep the loonies on the path ...

Similar Threads

  1. 2D OpenGL text rendering with existing app
    By bytebucket in forum Newbie
    Replies: 7
    Last Post: 11th March 2010, 20:28
  2. OpenGL rendering and threads
    By brcain in forum Qt Programming
    Replies: 2
    Last Post: 3rd July 2008, 09:45
  3. for the openGl to work should the direct rendering be enabled
    By babu198649 in forum General Programming
    Replies: 1
    Last Post: 27th April 2008, 15:22
  4. problem in rendering opengl on QGraphicsView
    By Sandip in forum Qt Programming
    Replies: 17
    Last Post: 15th April 2008, 08:27
  5. OpenGL rendering problem
    By spud in forum Qt Programming
    Replies: 5
    Last Post: 27th February 2007, 19:44

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.