PDA

View Full Version : DLL Project + QWidget in external software.



Adraesh
29th October 2012, 14:20
Hello !

First I appologize for my english, I'm french.

I'm building a DLL who contains QWidgets. This DLL is launch by an external software (Flight Simulator X).

I have to SetParent() my Qt window to FSX, but the result is not good ...

I have spent several hours trying to solve this issue but I didn't ...

The problem is that my Qt window is not displaying correctly even not displaying, the style of the Qt window is deleted etc...

If I don't SetParent() my Qt window and FSX main window, my Qt window is displaying correctly.



HWND lFsxHandle=FindWindow(L"FS98MAIN", NULL);
HINSTANCE hInstance = (HINSTANCE)GetWindowLong(lFsxHandle, GWL_HINSTANCE);

SimConnect_SetSystemState(gSimConnect, "DialogMode", 1, 0, NULL);

qint32 argc = 1;
char *argv[] = {"SDManager"};
int result;

QApplication lA(argc, argv);
SDManagerFenetre lF;
SetParent(lF.winId(), lFsxHandle);
lF.show();
result = lA.exec();

SimConnect_SetSystemState(gSimConnect, "DialogMode", 0, 0, NULL);


I click on my button who trigger the QtWidget.show() :

8377

When I just clik on the Windows Start Button my QtWidget appear :

8378

I can find my QtWidget using my mouse to rezize etc .. :

8379

I give you my creation code of my Qwidget :

cpp :


#include "StdAfx.h"
#include "SDManagerFenetre.h"


SDManagerFenetre::SDManagerFenetre(QWidget *parent) : QWidget(parent)
{
resize(512, 512);
setWindowTitle(tr("SkyDream Manager"));
}

SDManagerFenetre::~SDManagerFenetre()
{

}

void SDManagerFenetre::showEvent(QShowEvent *event)
{
Q_UNUSED(event);

CenterOnScreen();
}

void SDManagerFenetre::CenterOnScreen()
{
QDesktopWidget screen;

QRect screenGeom = screen.screenGeometry(this);

int screenCenterX = screenGeom.center().x();
int screenCenterY = screenGeom.center().y();

move(screenCenterX - width () / 2,
screenCenterY - height() / 2);
}


.h :


#pragma once
#include <QtGui>

class SDManagerFenetre : public QWidget
{
public:
SDManagerFenetre(QWidget *parent = 0);
~SDManagerFenetre(void);
protected:
void showEvent(QShowEvent *event);

private:
void CenterOnScreen();
};


Have u an idea ? Thank you in advance.

Adraesh
30th October 2012, 10:22
I thought it was a repaint engine issue, and I tried to use this :


AA_MSWindowsUseDirect3DByDefault

public static final Qt.ApplicationAttribute AA_MSWindowsUseDirect3DByDefault

Is a Windows specific attribute, that will make the Direct3D paint engine the default Qt widget paint engine. Note that you can toggle usage of the Direct3D engine on individual QWidgets by setting/clearing the WA_MSWindowsUseDirect3D attribute on a specific widget. This functionality is experimental.

But same thing my window doesn't displaying good when it SetParent with "FS98MAIN"

Thank you.