Results 1 to 4 of 4

Thread: Display a Label on top of a QGlWidget

  1. #1
    Join Date
    Jan 2006
    Posts
    122
    Thanks
    16
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Display a Label on top of a QGlWidget

    Hi,
    I would like to display a QLabel (basically just a text) on top of an QGlWidget.
    In paintGL() I render my OpenGL stuff, I would like to have a number displayed over the OpenGL context.
    I tried overriding paintEvent but I think the Gl context is always on top.
    Any idea?

    Thanks in advance

    Qt Code:
    1. void Player::paintEvent(QPaintEvent *event)
    2. {
    3.  
    4. QPainter painter(this);
    5. painter.setRenderHint(QPainter::Antialiasing);
    6. painter.drawText(250, 250, "1");
    7. QGLWidget::paintEvent(event);
    8. }
    To copy to clipboard, switch view to plain text mode 

  2. #2
    Join Date
    Oct 2006
    Location
    New Delhi, India
    Posts
    2,467
    Thanks
    8
    Thanked 334 Times in 317 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Display a Label on top of a QGlWidget

    I am not much aware of OpenGL, but will changing the order help you ??

    Qt Code:
    1. QGLWidget::paintEvent(event);
    2. QPainter painter(this);
    3. painter.setRenderHint(QPainter::Antialiasing);
    4. painter.drawText(250, 250, "1");
    To copy to clipboard, switch view to plain text mode 

  3. #3
    Join Date
    Jan 2006
    Posts
    122
    Thanks
    16
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Display a Label on top of a QGlWidget

    No, in fact before I put
    Qt Code:
    1. QGLWidget::paintEvent(event);
    To copy to clipboard, switch view to plain text mode 
    at the beginning.
    It's displayed just few seconds before the OpenGL start rendering.

  4. #4
    Join Date
    Jan 2006
    Posts
    122
    Thanks
    16
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Display a Label on top of a QGlWidget

    Maybe should I use something else rather than QLabel?
    Any idea?
    Thanks

Similar Threads

  1. Display only PNG image on desktop
    By durbrak in forum Qt Programming
    Replies: 32
    Last Post: 15th March 2008, 21:55
  2. QGLWidget with multiple monitors
    By Rayven in forum Qt Programming
    Replies: 3
    Last Post: 4th August 2006, 10:28

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.