[Qt-interest] Works in 4.53, but not 4.6.

Trond Kjernaasen trond at trolltech.com
Mon Dec 28 16:40:21 CET 2009


Hi Scott,

Freak . wrote:
> 
> 
> On Tue, Dec 22, 2009 at 10:46 PM, Bachrach, Robert L 
> <rob.bachrach at tycoelectronics.com 
> <mailto:rob.bachrach at tycoelectronics.com>> wrote:
> 
>     I use a 3rd party library that draws its own 3D graphics to a
>     QtWidget.  Although I have not yet tried it with 4.6, it appears to
>     set the following in the windows constructor:
> 
>            setAttribute(Qt::WA_NoSystemBackground);
>            setBackgroundRole( QPalette::NoRole);
> 
>     In theory, this should prevent Qt from drawing a background on the
>     widget and should prevent it from overwriting your graphics.
> 
>     Rob
> 
> 
> Thanks for the replies, but as i mentioned my code works fine on Qt4.53 
> by doing much of what you have mentioned, but Nokia/Trolltech have 
> removed the ability for custom paint events or so it would seem in 4.6.  
> I would be interested to see if you have the same issue in 4.6.
> 
> I would really like to know what the "-direct3d" switch was doing during 
> "configure" there is so little info on this subject, getting D3D working 
> initially was a miracle in itself, but it's been working fine it very 
> disappointing to spend time learning a framework that seems to be non 
> useful to me now.

The -direct3d switch just enabled the compilation and inclusion of the 
D3D QPainter backend into Qt, which was removed in 4.6.

> I'm actually using some CUDA and Nvidia Nexus MSVC debugging tools, and 
> using the -direct3d switch was giving me errors about not being a D3D10 
> application, it was actually D3D10, but looking carfully at dependencies 
> Qt was using D3D9.dll's as well as my D3D10.dll files. By using 4.6 i do 
> solve this problem because there is no -direct3d switch, but i'm left 
> with a program that now fights on the paintevent.
> 
> Here is a quick simple D3D9 code example (because it's simpler and more 
> people may be able to run it) My D3D10 code is different but the same 
> problems are exhibited.
> 
> You will see the code should draw just pain black window, instead it's 
> grey unless you resize and you can see the black flicker underneath.  If 
> anyone can compile or tell me how to get this to work or more info on 
> where to look, i would be forever grateful, as it's been very 
> frustrating..... Grrr....
> 
> {S Samuel, i will read your reply again to let it soak, but using 
> "setUpdatesEnabled(false);" made the window draw white instead, so i 
> really want no background but i'm always getting one.
> 
> All ideas welcomed.
> 
> Cheers,
> Scott.

There are two things you need to do/take care of, in order to get your 
D3D drawing to work:

1) setAttribute(Qt::WA_PaintOnScreen) (which you already do).

2) You *have* to reimplement QWidget::paintEngine() in your iD3D9 class 
(note that it's a const function) and have it return 0. Otherwise the 
WA_PaintOnScreen attribute won't have any effect. This is actually 
documented in the Widget Attributes section.

In addition, be aware that when Qt reparents native widgets, their 
winId() changes. That means, if you move a widget from one parent into 
another, your D3D drawing will most likely stop working unless you set 
it up again with the new window id.

Regards,
--
Trond K.



More information about the Qt-interest-old mailing list