[Qt-interest] Qt, DirectX and MultiThreading

Ender EREL erelender at yahoo.com
Fri Apr 16 16:34:34 CEST 2010


Ross Bencina wrote:
> Hmm yeah. There must be a way to get the timer events delivered in the 
> main thread while a dialog is visible (I hope, since I have a similar 
> problem to solve sooner or later)...
> 
> Perhaps you could just have another thread (or windows timer) post a 
> custom QEvent back to the main window to trigger the repaint -- 
> hopefully custom events don't get filtered while the dialog is visible.
> 

Never used custom events before, but it might work. As soon as i have 
time, i will try that.

> 
> Well, my first question is, does the Widget whose HWND you're using with 
> DirectX have the Qt::WA_NativeWindow attribute set? Try that. Also make 
> sure you request the HWND _after_ your widget has been shown (even if 
> you have to show it outside visible bounds). I had all sorts of problems 
> getting Qt to give me a stable HWND until I followed these steps. 
> Calling WinId() is not enough.
> 

Yes, it does (tried both ways). I was requesting HWND at the constructor 
but changed it, now i am requesting it after the widget is shown (inside 
visible bounds). Nothing changes.


> Failing that, I'm a bit hazy on this, but I thought  you're only 
> supposed to talk to a HWND in the thread in which you created it (check 
> MSDN for details)... so you might need to create your DX hosting HWND in 
> your second thread and parent it to the HWND from the main thread. Could 
> be wrong about that though...
> 
> Good luck!
> 
> Ross.

Yeah, the problem seems to be caused by this. I can't create the host 
hwnd in the render thread because, well, Qt docs say it's forbidden.

I gave up on triggering rendering from the second thread because of 
this. Now i am trying to find a way to call my rendering function while 
a dialog is shown.

Best Regards.
-- 
Ender EREL -  -



More information about the Qt-interest-old mailing list