Results 1 to 4 of 4

Thread: Widgets on top of a QGLWidget

  1. #1
    Join Date
    Jun 2008
    Posts
    88
    Thanks
    4
    Thanked 4 Times in 3 Posts
    Qt products
    Qt3 Qt4
    Platforms
    MacOS X Unix/X11
    Wiki edits
    1

    Default Widgets on top of a QGLWidget

    I'm making an OpenGL widget with some Qt controls sitting on top of it. The OpenGL widget is used for playing back images (ie. .mov files) and the controls are playback controls.

    The playback controls are parented to a vanilla QWidget which is then parented to the QGLWidget. I want the vanilla QWidget to have a transparent or partially transparent background so all you can see are the playback controls. I've tried the following but all I get is garbage as the background.

    Qt Code:
    1. setBackgroundRole(QPalette::Base);
    2. pal.setColor(QPalette::Base, QColor(Qt::transparent));
    3. setPalette(pal);
    To copy to clipboard, switch view to plain text mode 
    Is there a good way to integrate a QWidget into an OpenGL? Any widget attributes or paint engine tricks? Essentially I want to make the playback controls look like they're painted as an overlay in OpenGL.

    FYI I do not have a compositing window manager

  2. #2
    Join Date
    May 2009
    Posts
    16
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Widgets on top of a QGLWidget

    Yes. There's a wiki entry about this here:

    http://wiki.qtcentre.org/index.php?t...ts_with_OpenGL

    There's also some sample code to download and compile. This is a bit more complicated than a plain QGLWidget, but it seems to work pretty well.

  3. #3
    Join Date
    Jun 2008
    Posts
    88
    Thanks
    4
    Thanked 4 Times in 3 Posts
    Qt products
    Qt3 Qt4
    Platforms
    MacOS X Unix/X11
    Wiki edits
    1

    Default Re: Widgets on top of a QGLWidget

    Yup, that seems like the right way to go. Unfortunately for me I inherited an existing code base and probably can't refactor it to put the OpenGL widget in a graphics view.

    I might just have to do what VLC does in Gnome and just have it animate a floating widget above the OpenGL window sans opacity. Thanks for the response, perhaps I can try to refactor the code later.

  4. #4
    Join Date
    May 2009
    Posts
    16
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Widgets on top of a QGLWidget

    I actually had an old codebase and managed to refactor it. It's not as bad as you think -- obviously have a backup handy before you attempt it, though.

Similar Threads

  1. Replies: 0
    Last Post: 17th November 2009, 21:19
  2. Replies: 1
    Last Post: 23rd April 2009, 09:05
  3. Upper limit on number of widgets?
    By jdiewald in forum Qt Programming
    Replies: 1
    Last Post: 29th September 2008, 23:00
  4. Replies: 2
    Last Post: 16th May 2008, 14:39
  5. Transparent widgets on top of QGLWidget
    By tseval in forum Qt Programming
    Replies: 1
    Last Post: 12th May 2007, 21:03

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.