Results 1 to 2 of 2

Thread: Problem with QGLWidget paint events in Qt 4.6

  1. #1
    Join Date
    Aug 2007
    Posts
    13
    Thanks
    3
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Problem with QGLWidget paint events in Qt 4.6

    I recently updated my Qt 4.3 to 4.6. With that said, in my QGLWidget sub class I reimplemented the paint event where a background brush was drawn using QPainter. Then I would call my OpenGL calls to draw over the background. This worked perfectly in earlier versions of Qt, but 4.6 seems to just draw over my OpenGL graphics.

    I understand that the OpenGL paint system has been overhauled in this release. But I really need this functionality to work in this version and any future releases. Any help would be appreciated. Thanks.

    Here is a snippet of my code.

    Qt Code:
    1. class gfx : public QGLWidget
    2. {
    3. Q_OBJECT
    4. /* code */
    5. protected:
    6. void paintEvent(QPaintEvent *event);
    7. /* more code */
    8. };
    9.  
    10. static void drawBackGround(QPainter *painter)
    11. {
    12. painter->setPen(Qt::NoPen);
    13. painter->setBrush(mBackground); /* some brush for my background */
    14. painter->drawRect(rect());
    15. }
    16. void gfx::paintEvent(QPaintEvent *event)
    17. {
    18. Q_UNUSED(event)
    19. QPainter painter(this);
    20.  
    21. drawBackGround(&painter);
    22.  
    23. draw(); // openGL calls
    24. event->setAccepted(true);
    25. }
    To copy to clipboard, switch view to plain text mode 

  2. #2
    Join Date
    Nov 2008
    Location
    Częstochowa/Poland
    Posts
    50
    Thanks
    2
    Thanked 11 Times in 11 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Problem with QGLWidget paint events in Qt 4.6

    Have You tried using void QGLWidget::qglClearColor ( constQColor& c) const
    Me, Grimlock, not "nice dino". ME BASH BRAINS!

Similar Threads

  1. Strange problem with events on Unix
    By sukanyarn in forum Qt Programming
    Replies: 2
    Last Post: 7th November 2006, 02:45
  2. Using QGLWidget paint engine to draw regular widgtes?
    By high_flyer in forum Qt Programming
    Replies: 11
    Last Post: 9th October 2006, 12:06
  3. Problem with receiving events from QDateEdit
    By gunhelstr in forum Qt Programming
    Replies: 4
    Last Post: 20th April 2006, 11:21
  4. QGLWidget renderText problem
    By mbjerkne in forum Qt Programming
    Replies: 1
    Last Post: 7th April 2006, 21:35
  5. Replies: 16
    Last Post: 7th March 2006, 15:57

Tags for this Thread

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.