I’m trying to use SDL to update a Qt widget. So i tried the window id
hack, but I wasn’t successfull and I can’t find help anywhere. What I did:
made the qwidget
got its window id (with the winId() method)
used the id to set SDL_WINDOWID env variable
4 tried to use SDL on that window.
Since this is asked so often it qualifies as a FAQ, but nobody has ever
answered it, I took a crack at it myself with your steps as a starting
point (thanks!)
And… I got it!
The attached archive builds a simple Qt application qtSDL, which creates an
SDL “screen” widget, and if sample.bmp resides in the current directory,
blits that to the center of the widget. This screen widget correctly handles
resizing, paint events, and drawing interactions with Qt. Note that SDL no
longer handles events for the screen at this point, so you’ll have to do all
your actions based on Qt signals.
I have also tried to do such a thing, but never managed to do it. It will
be really useful (at least for me !).
Julien> ----- Original Message -----
From: slouken@devolution.com (Sam Lantinga)
To:
Sent: Tuesday, January 21, 2003 8:01 AM
Subject: Re: [SDL] Help with SDL inside QT
I’m trying to use SDL to update a Qt widget. So i tried the window id
hack, but I wasn’t successfull and I can’t find help anywhere. What I
did:
made the qwidget
got its window id (with the winId() method)
used the id to set SDL_WINDOWID env variable
4 tried to use SDL on that window.
Since this is asked so often it qualifies as a FAQ, but nobody has ever
answered it, I took a crack at it myself with your steps as a starting
point (thanks!)
And… I got it!
The attached archive builds a simple Qt application qtSDL, which creates
an
SDL “screen” widget, and if sample.bmp resides in the current directory,
blits that to the center of the widget. This screen widget correctly
handles
resizing, paint events, and drawing interactions with Qt. Note that SDL
no
longer handles events for the screen at this point, so you’ll have to do
all
your actions based on Qt signals.
That’s exactly what I was looking for. I was going to solve the problem
in another way but now i can do what i wanted in the first place.
Thanks a lot!
Sam Lantinga wrote:>>I’m trying to use SDL to update a Qt widget. So i tried the window id
hack, but I wasn’t successfull and I can’t find help anywhere. What I did:
made the qwidget
got its window id (with the winId() method)
used the id to set SDL_WINDOWID env variable
4 tried to use SDL on that window.
Since this is asked so often it qualifies as a FAQ, but nobody has ever
answered it, I took a crack at it myself with your steps as a starting
point (thanks!)
And… I got it!
The attached archive builds a simple Qt application qtSDL, which creates an
SDL “screen” widget, and if sample.bmp resides in the current directory,
blits that to the center of the widget. This screen widget correctly handles
resizing, paint events, and drawing interactions with Qt. Note that SDL no
longer handles events for the screen at this point, so you’ll have to do all
your actions based on Qt signals.
Thanks for the SDL and Qt example program! I was wondering though if there
was any chance of mixing this with full screen mode. I would love to be able
to use SDL for the low level graphics and its ability to toggle between full
screen and window mode and also to use Qt for the user interface code.
For example I want to have an application that can be full screen or not but
it also has to pop up screens for user input and configuration and the mix of
SDL and Qt would be great!–
Brad Pepers @Brad_Pepers
Thanks for the SDL and Qt example program! I was wondering though if there
was any chance of mixing this with full screen mode. I would love to be able
to use SDL for the low level graphics and its ability to toggle between full
screen and window mode and also to use Qt for the user interface code.
Nope, I can’t think of any simple way to do that.
You might be able to convince Qt to use an existing SDL window as a toplevel
widget… ?
See ya,
-Sam Lantinga, Software Engineer, Blizzard Entertainment
Nope, I can’t think of any simple way to do that.
You might be able to convince Qt to use an existing SDL window as a
toplevel widget… ?
I think I can call create(wid, false, true) in a QWidget constructor to make
it use an existing window id. How do I get the window id from SDL though?
Of course this would likely all end up being really platform specific as well
which is something I want to ignore so perhaps its just best to figure out a
good SDL GUI library to use and dump Qt. But thought I’d see how far I can
get with mixing SDL and Qt!–
Brad Pepers @Brad_Pepers
Nope, I can’t think of any simple way to do that.
You might be able to convince Qt to use an existing SDL window as a
toplevel widget… ?
I think I can call create(wid, false, true) in a QWidget constructor to make
it use an existing window id. How do I get the window id from SDL though?
Use the SDL_syswm.h interface. There’s some code in the FAQ which shows
how to get the SDL window id and move the X11 window around. Theoretically
you could use the same interface to get the Windows window HANDLE and do
the same thing there…
Of course this would likely all end up being really platform specific as well
which is something I want to ignore so perhaps its just best to figure out a
good SDL GUI library to use and dump Qt. But thought I’d see how far I can
get with mixing SDL and Qt!
I’ve heard good things about ParaGUI, available from the libraries page.
See ya,
-Sam Lantinga, Software Engineer, Blizzard Entertainment