in Education by
I have a dll, which use OpenGl to draw on window. Dll get window by HWMD. DLL: extern "C" __declspec(dllexport) int Init(HWND hWnd); extern "C" __declspec(dllexport) void Resize(HWND hWnd, int w, int h); extern "C" __declspec(dllexport) void Paint(HWND hWnd); The c++ qt application is work properly. #include "windows.h" #include #include #include #include #include #include typedef void (*InitPrototype)(HWND); typedef void (*PaintPrototype)(HWND); typedef void (*ResizePrototype)(HWND, int, int); InitPrototype c_Init; PaintPrototype c_Paint; ResizePrototype c_Resize; bool load_opengl_library(){ QLibrary lib("engine3d"); lib.load(); c_Init = (InitPrototype)lib.resolve("Init"); c_Paint = (PaintPrototype)lib.resolve("Paint"); c_Resize = (ResizePrototype)lib.resolve("Resize"); return true; } class MyGlWidget: public QGLWidget { public: MyGlWidget(QWidget *parent = 0): QGLWidget(parent){} void showEvent(QShowEvent* event){ c_Init((HWND)(this->winId())); } void paintEvent(QPaintEvent* event){ c_Paint((HWND)this->winId()); } void resizeEvent(QResizeEvent* event){ c_Resize((HWND)this->winId(), this->width(), this->height()); } }; int main(int argc, char *argv[]) { QApplication a(argc, argv); load_opengl_library(); MyGlWidget w; w.show(); return a.exec(); } But how do the same in python? My program crushes on sending widget.winId(). # coding=utf-8 import ctypes from PyQt5 import QtWidgets, QtOpenGL app = QtWidgets.QApplication([]) e3d = ctypes.CDLL(r"engine3d.dll") init = lambda hwnd: e3d.Init(hwnd) paint = lambda hwnd: e3d.Paint(hwnd) resize = lambda hwnd, w, h: e3d.Paint(hwnd, w, h) class MyGLWidget(QtOpenGL.QGLWidget): def __init__(self): super().__init__() def showEvent(self, ev): init(self.winId()) def paintEvent(self, ev): paint(self.winId()) def resizeEvent(self, ev): resize(self.winId(), self.width(), self.height()) w = MyGLWidget() w.show() app.exec_() print(self.winId()) is JavaScript questions and answers, JavaScript questions pdf, JavaScript question bank, JavaScript questions and answers pdf, mcq on JavaScript pdf, JavaScript questions and solutions, JavaScript mcq Test , Interview JavaScript questions, JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)

1 Answer

0 votes
by
It'd be easier to check having the dll, so I'll speak out the blue. In your c++ code you got this initialization code: bool load_opengl_library(){ QLibrary lib("engine3d"); lib.load(); c_Init = (InitPrototype)lib.resolve("Init"); c_Paint = (PaintPrototype)lib.resolve("Paint"); c_Resize = (ResizePrototype)lib.resolve("Resize"); return true; } ... int main(int argc, char *argv[]) { QApplication a(argc, argv); load_opengl_library(); MyGlWidget w; w.show(); return a.exec(); } Where you create your engine instance liband using loadmethod but in python you're not doing anything of that: w = MyGLWidget() w.show() app.exec_() But before creating the MyGLWidget you're not initializing your engine as its c++ counterpart, question is, why not?

Related questions

0 votes
    I want to execute HelloWorldConsole.exe with an shipped Mono Framework through Go. So I want to call mono- ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 17, 2022 in Education by JackTerrance
0 votes
    I write a tool, It can get device id through the dll, and copy the id to clipboard. extern crate ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 2, 2022 in Education by JackTerrance
0 votes
    I'm using a 3rd party DLL written in unmanaged C++ that controls some hardware we have. Unfortunately ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 11, 2022 in Education by JackTerrance
0 votes
    I'm using a 3rd party DLL written in unmanaged C++ that controls some hardware we have. Unfortunately ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 11, 2022 in Education by JackTerrance
0 votes
    I'm using a 3rd party DLL written in unmanaged C++ that controls some hardware we have. Unfortunately ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 5, 2022 in Education by JackTerrance
0 votes
    I'm using a 3rd party DLL written in unmanaged C++ that controls some hardware we have. Unfortunately ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 5, 2022 in Education by JackTerrance
0 votes
    When I'm calling a Dll method it sometimes throws an exception, and sometimes doesn't. I'm calling ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Feb 20, 2022 in Education by JackTerrance
0 votes
    I have a managed C++ dll which uses a unmanaged C++ lib. I've added the lib file in the ... , JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Feb 16, 2022 in Education by JackTerrance
0 votes
    I'm developing a plugin. Take a look at the following code. string request(char post_params[]) { CURL *curl; CURLcode res; std:: ... .) { std::ofstream file ("d:/t/t.txt"); file...
asked Feb 15, 2022 in Education by JackTerrance
0 votes
    In my dll there is a method that I want to export. //Works: extern "C" __declspec(dllexport) // ... , JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Feb 13, 2022 in Education by JackTerrance
0 votes
    In my dll there is a method that I want to export. //Works: extern "C" __declspec(dllexport) // ... , JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Feb 13, 2022 in Education by JackTerrance
0 votes
    In my dll there is a method that I want to export. //Works: extern "C" __declspec(dllexport) // ... , JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Feb 13, 2022 in Education by JackTerrance
0 votes
    In my dll there is a method that I want to export. //Works: extern "C" __declspec(dllexport) // ... , JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Feb 13, 2022 in Education by JackTerrance
0 votes
    What will be the output of the following Python code? >>>list1 = [1, 3] >>>list2 = list1 >>>list1[0] = 4 >>>print(list2) a) [1, 4] b) [1, 3, 4] c) [4, 3] d) [1, 3]...
asked Jan 2, 2023 in Technology by JackTerrance
0 votes
    What will be the output of the following Python code? print('*', "abcde".center(6), '*', sep='') a) * abcde * b) *abcde * c) * abcde* d) * abcde *...
asked Jan 2, 2023 in Technology by JackTerrance
...