Results 1 to 2 of 2

Thread: DLL Project + QWidget in external software.

  1. #1
    Join Date
    Oct 2012
    Posts
    11

    Default DLL Project + QWidget in external software.

    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.

    Qt Code:
    1. HWND lFsxHandle=FindWindow(L"FS98MAIN", NULL);
    2. HINSTANCE hInstance = (HINSTANCE)GetWindowLong(lFsxHandle, GWL_HINSTANCE);
    3.  
    4. SimConnect_SetSystemState(gSimConnect, "DialogMode", 1, 0, NULL);
    5.  
    6. qint32 argc = 1;
    7. char *argv[] = {"SDManager"};
    8. int result;
    9.  
    10. QApplication lA(argc, argv);
    11. SDManagerFenetre lF;
    12. SetParent(lF.winId(), lFsxHandle);
    13. lF.show();
    14. result = lA.exec();
    15.  
    16. SimConnect_SetSystemState(gSimConnect, "DialogMode", 0, 0, NULL);
    To copy to clipboard, switch view to plain text mode 

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

    1_20121024-1220.jpg

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

    2.jpg

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

    3.jpg

    I give you my creation code of my Qwidget :

    cpp :
    Qt Code:
    1. #include "StdAfx.h"
    2. #include "SDManagerFenetre.h"
    3.  
    4.  
    5. SDManagerFenetre::SDManagerFenetre(QWidget *parent) : QWidget(parent)
    6. {
    7. resize(512, 512);
    8. setWindowTitle(tr("SkyDream Manager"));
    9. }
    10.  
    11. SDManagerFenetre::~SDManagerFenetre()
    12. {
    13.  
    14. }
    15.  
    16. void SDManagerFenetre::showEvent(QShowEvent *event)
    17. {
    18. Q_UNUSED(event);
    19.  
    20. CenterOnScreen();
    21. }
    22.  
    23. void SDManagerFenetre::CenterOnScreen()
    24. {
    25.  
    26. QRect screenGeom = screen.screenGeometry(this);
    27.  
    28. int screenCenterX = screenGeom.center().x();
    29. int screenCenterY = screenGeom.center().y();
    30.  
    31. move(screenCenterX - width () / 2,
    32. screenCenterY - height() / 2);
    33. }
    To copy to clipboard, switch view to plain text mode 

    .h :

    Qt Code:
    1. #pragma once
    2. #include <QtGui>
    3.  
    4. class SDManagerFenetre : public QWidget
    5. {
    6. public:
    7. SDManagerFenetre(QWidget *parent = 0);
    8. ~SDManagerFenetre(void);
    9. protected:
    10. void showEvent(QShowEvent *event);
    11.  
    12. private:
    13. void CenterOnScreen();
    14. };
    To copy to clipboard, switch view to plain text mode 
    Have u an idea ? Thank you in advance.

  2. #2
    Join Date
    Oct 2012
    Posts
    11

    Default Re: DLL Project + QWidget in external software.

    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.

Similar Threads

  1. Replies: 0
    Last Post: 24th May 2012, 14:58
  2. Qt Creator How to add an external .a library in Qt Creator project via GUI?
    By DIMEDROLL in forum Qt Tools
    Replies: 1
    Last Post: 7th January 2012, 08:11
  3. Replies: 0
    Last Post: 16th June 2011, 20:52
  4. Client-Server software project design question
    By MarkoSan in forum Qt Programming
    Replies: 7
    Last Post: 25th March 2008, 10:31

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.