Results 1 to 4 of 4

Thread: Using QWidgets on QGLWidget for 3D game interface

  1. #1
    Join Date
    Mar 2008
    Posts
    11
    Thanks
    1
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Question Using QWidgets on QGLWidget for 3D game interface

    I'm experimenting with using Qt as the GUI back-end for a 3D game but during my experiments with QGLWidget I've ran into some issues that hopefully some of you can help resolve or offer better implementation ideas.

    Approach 1: Create a QGLWidget, and use it as the parent of regular QWidgets, let Qt manage drawing.
    This seems to achieve the general idea of using QWidgets as an overlay for a GL window however I am unsure on the correct method for drawing. For the game loop I would ideally update the GL window via timer using updateGL() and have the widgets draw afterward (with transparency). So far I have been able to draw opaque widgets but I have been unable to make a widget draw with either background brush transparency or full transparency (I'm probably doing it wrong). Another concern is the speed of drawing the Widgets ontop as I am unaware of the internals going on with Qt and GL (is it using an internal overlay?)

    Approach 2: Create QGLWindow, Widgets(hidden), draw widgets to dynamicTextures.
    Another idea I had was to create a Widget and draw to a dynamic texture applied to a GL surface. This could be done using by changing the widget paintEvent or using grabWidget somewhere. The mouse events in the GLWidget would need translated and redirected to the corresponding Widgets depicted by the textured GL surface. This probably doesn't solve the transparency issue either, however making rects in GL transparent is easy, but not the best way as I may not want QLabel text to be transparent, just the background.

    If there is some way I could put a Widget in a GLWidget, tell it not to draw (instead draw to the dynamicTexture), but still handle mouse clicks for the area it *would* draw to, then that would just be peachy

    Approach 1 is the simplest but Approach 2 is most likely way faster.
    Any help/ideas would be appreciated.

  2. #2
    Join Date
    Jan 2008
    Posts
    4
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Using QWidgets on QGLWidget for 3D game interface

    i had the same problem and solved it using something like your second approach.

    it is working, but it is not perfect, specially for qt < 4.4, i think because of the new introduced alien widgets. for qt 4.4 i get usable results.

    i am likely to share my code, with the hope of getting better results.

    please leave a private message, if you are interested.

  3. #3
    Join Date
    Feb 2010
    Posts
    2
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Using QWidgets on QGLWidget for 3D game interface

    Hello, I am a newbee in QT. I need to draw a QTextEdit control on top of a work area which is a QGLWidget. I would appreciate if you share your code on this problem with me. I will test it if it is applicable and share my experience with you. I hope that many will benefit from it.
    Thank you in advance! send it to ariunaa_bertelsen@hotmail.com

  4. #4
    Join Date
    Feb 2010
    Posts
    2
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Using QWidgets on QGLWidget for 3D game interface

    Hello, I am a newbee in QT. I need to draw a QTextEdit control on top of a work area which is a QGLWidget. I would appreciate if you share your code on this problem with me. I will test it if it is applicable and share my experience with you. I hope that many will benefit from it.
    Thank you in advance! send it to ariunaa_bertelsen@hotmail.com

Similar Threads

  1. Qt interface running extremely slowly...
    By jazztpt in forum Qt Programming
    Replies: 1
    Last Post: 4th February 2006, 11:12

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.