Results 1 to 12 of 12

Thread: Using QGLWidget paint engine to draw regular widgtes?

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,360
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Using QGLWidget paint engine to draw regular widgtes?

    Quote Originally Posted by high_flyer View Post
    Could you explain a bit more on how you would do such a thing?
    I mean, how would the QPainter be delivered to the QPushButton paintEvent?
    Hmm... let's think about it... Maybe through some external object holding a pointer to the painter which would be updated every time the GLPainter is created. It's just a loose concept, but if there was a pointer to the painter available, one could read it through that object and use it. Of course after clipping and transforming coordinates. The problem I see is that the painter object is only created (at least I think so) when the top level widget is updated (correct me if I'm wrong), so updating a child widget would require creating such a painter first. As I said, just a loose concept and a bit unclear one, I don't have a slightest idea if this is achievable at all.

  2. #2
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,714
    Thanks
    21
    Thanked 418 Times in 411 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: Using QGLWidget paint engine to draw regular widgtes?

    but if there was a pointer to the painter available, one could read it through that object and use it.
    That is the point I don't get.
    Lets say I have a pointer to the openGL QPainter, in a helper object or some other place.
    How can I give it to a regular QWidget subclass (not a user subclass,but like QPushButton) in order that it will use it for drawing it self...

    That is the main problem I am trying to solve (if it can be solved).

    Thanks for helping out with the brainstorming!

  3. #3
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,360
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Using QGLWidget paint engine to draw regular widgtes?

    You can't. That's why I said you have to subclass

  4. #4
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,714
    Thanks
    21
    Thanked 418 Times in 411 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: Using QGLWidget paint engine to draw regular widgtes?

    Hehe... ok, I thought you were suggesting to give the QPainter pointer to the Qt widgets...
    I know it not possible with the Qt API (at least I could not find how), that is why I posted the question...

    Hmm... I am not yet sure in which direction to go...
    I mean, this will have to do with reimplementing the PaintEngine, which is created by the PaintDevice, which is the base for QWidget...

    I have to read some more...

    Thanks.

  5. #5
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,360
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Using QGLWidget paint engine to draw regular widgtes?

    Reading one of the other threads in this forum I came up with an idea - maybe redirecting QPainter (QPainter::setRedirected) could help? You could redirect painting child widgets to the parent (GL based) widget's painter. It is probable that you should do some transforming/clipping of the GL painter to make it work (or maybe using the "offset" param will be enough).

  6. #6
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,714
    Thanks
    21
    Thanked 418 Times in 411 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: Using QGLWidget paint engine to draw regular widgtes?

    That looks interesting!
    I'll have a look at it - thanks.

  7. #7
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,714
    Thanks
    21
    Thanked 418 Times in 411 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: Using QGLWidget paint engine to draw regular widgtes?

    Hi again,

    I just wanted to add that I tried QPainter::setRedirected, and it works in the sence that you can use it to draw the controls in a GL context.
    I do it by first redirecting the draw event of the widget I want on to a QPixmap, and then I use a GL initiated QPainter to draw this pixmap in GL context.
    The problem is, that this only DRAWS the controls in GL, so these are not real object anymore under GL...
    It looks like having 'responding objects' under GL will force me to do sume subclassing after all...

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.