[Qt-interest] Works in 4.53, but not 4.6.
Freak .
mentalcodes at gmail.com
Wed Dec 23 01:42:01 CET 2009
On Tue, Dec 22, 2009 at 10:46 PM, Bachrach, Robert L <
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.
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.
Code will compile and work fine if D3D9 and Qt are installed.
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//"main.cpp"
#include "mainwindow.h"
#include "iD3D9.h"
#include <QtGui/QApplication>
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
QMainWindow window;
iD3D9 widget;
window.setCentralWidget(&widget);
widget.InitD3D();
window.show();
return a.exec();
//"iD3D9.h"
#include <QWidget>
class iD3D9 : public QWidget
{
Q_OBJECT
public:
iD3D9(QWidget *parent = 0, Qt::WFlags flags = 0);
~iD3D9();
void InitD3D();
bool PaintD3D();
private:
void paintEvent(QPaintEvent *p);
};
//"iD3D9.cpp"
"#include "iD3D9.h"
#include <d3d9.h>
//Globals//
LPDIRECT3D9 g_pD3D = NULL; // Used to create the D3DDevice
LPDIRECT3DDEVICE9 g_pd3dDevice = NULL; // Our rendering device
iD3D9::iD3D9(QWidget *parent, Qt::WFlags flags) //
: QWidget(parent, flags)
{
setFixedSize(200, 200);
setAttribute(Qt::WA_MSWindowsUseDirect3D, true);
setAttribute(Qt::WA_NoSystemBackground, true);
}
iD3D9::~iD3D9() //
{
}
void iD3D9::InitD3D()
{
g_pD3D = Direct3DCreate9( D3D_SDK_VERSION); //Standard
D3DPRESENT_PARAMETERS d3dpp;
ZeroMemory( &d3dpp, sizeof(d3dpp) );
d3dpp.Windowed = TRUE;
d3dpp.SwapEffect = D3DSWAPEFFECT_DISCARD;
d3dpp.BackBufferFormat = D3DFMT_UNKNOWN;
d3dpp.EnableAutoDepthStencil = TRUE;
d3dpp.AutoDepthStencilFormat = D3DFMT_D16;
g_pD3D->CreateDevice( D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, winId(), //
DXREF Hardware Vertex GPU
D3DCREATE_HARDWARE_VERTEXPROCESSING,
&d3dpp, &g_pd3dDevice );
};
void iD3D9::paintEvent(QPaintEvent *p) // We made our own paintEvent
{
PaintD3D();
}
bool iD3D9::PaintD3D()
{
if(g_pd3dDevice == 0)
return false;
g_pd3dDevice->Clear(0, 0, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER,
D3DCOLOR_XRGB(0, 0, 0), 1.0f, 0);
if(SUCCEEDED(g_pd3dDevice->BeginScene()))
{
g_pd3dDevice->EndScene();
}
g_pd3dDevice->Present( 0, 0, 0, 0 );
return true;
}
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20091223/8cc5efe3/attachment.html
More information about the Qt-interest-old
mailing list