Results 1 to 1 of 1

Thread: Double Buffering on QGLWidget - Background always grey

  1. #1
    Join Date
    Jan 2012
    Posts
    26
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Double Buffering on QGLWidget - Background always grey

    Hi,

    I would like to do double buffering on QGLWidget. I already did that on QWidget and it worked perfectly. I have a QPixmap and i call a function, to draw some stuff to the pixmap.

    Qt Code:
    1. func()
    2. {
    3. m_pixmap = QPixmap(size());
    4. m_pixmap.fill(this, 0, 0);
    5.  
    6. QPainter painter(&m_pixmap);
    7. painter.setRenderHint(QPainter::Antialiasing);
    8. painter.initFrom(this);
    9. // drawing
    To copy to clipboard, switch view to plain text mode 

    In my paintEvent() function I do:

    Qt Code:
    1. QStylePainter painter(this);
    2. painter.setRenderHint(QPainter::Antialiasing);
    3. painter.drawPixmap(0, 0, m_pixmap);
    To copy to clipboard, switch view to plain text mode 

    But when I do this, my bachground is always grey. The OpenGL background is overpainted.

    Any ideas why? And how can I fix this?

    If I draw my objects in paintEvent directly it works. But I would like to draw the pixmap.


    Added after 23 minutes:


    Solved! I had to set the QPixmap transparent.

    Qt Code:
    1. m_pixmap.fill(Qt::transparent);
    To copy to clipboard, switch view to plain text mode 
    Last edited by StarShaper; 31st March 2012 at 17:35.

Similar Threads

  1. qglwidget double buffering
    By vaibhav in forum Qt Programming
    Replies: 1
    Last Post: 27th July 2011, 18:03
  2. QLabel on top of a QGLWidget background issue
    By Rayven in forum Qt Programming
    Replies: 5
    Last Post: 5th April 2011, 18:34
  3. QgraphicsScene on QGLWidget background
    By ksrini in forum Qt Programming
    Replies: 2
    Last Post: 30th October 2009, 10:57
  4. double buffering
    By HelloDan in forum Newbie
    Replies: 10
    Last Post: 31st March 2009, 04:14
  5. Double Buffering for plot graphs
    By Tavit in forum Qt Programming
    Replies: 0
    Last Post: 20th March 2008, 14:10

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.