If the paper is original articles, reprint please indicate the original source This article blog: blog.csdn.net/qq21497936/…

Long-term continuous bring more projects and technology to share, consultation please add QQ:21497936, wechat: yangsir198808

Development technology set (including Qt practical technology, raspberry PI, 3D, OpenCV, OpenGL, FFMPEG, OSG, SCM, soft and hard combination, etc.) continue to update… (Click on the portal)

Qt Development Column: Development techniques

Next: Stay tuned…


preface

Use C# animation development, drawing performance can not keep up, replace the solution to use Qt development Qt controls made into OCX for C# calls, and activex is a more advanced form of OCX. QtCreator does not have Active control project, all need to use VS, the author uses VS2019 development.


The preparatory work

Qt5.15.2 + VS2019 + VS tools, build a basic development environment will not be described.


Develop the first Qt Activex: Hello World

Step 1: Create a Qt ActiveQt Server project

                 

Step 2: Drag a QLabel and type “Hello World”

  

Step 3: Generate error “MSB3073”

  You need to open VS2019 with administrator rights.

Step 4: Generate release and Debug versions

        

Step 5: Register the ActiveX control

Use Qt to register idc before running.

idc -regserver activeHelloWorldDemo.dll
Copy the code

  

Step 6: Call the activeQt control

Take a look, open the registry and search to confirm the CLSID, as shown below:Create an HTML and enter the following:

<html> <head> <title>activeQtDemo</title> </head> <body> <object id="object" classid="CLSID:2F12BFB8-137D-4DC2-9A93-634EFE5A6DFC"> <! -- The following is a pit --> <! -- classid="2F12BFB8-137D-4DC2-9A93-634EFE5A6DFC"> --> [Object not available!  Did you forget to build and register the server?]  </object> </body> </html>Copy the code

Running with IE, Active is Microsoft specific and not supported by other browsers, as shown below:


Into the pit

Pit one: Failed to invoke the control

The problem

  

why

Because the classid format is wrong

To solve

<html> <head> <title>activeQtDemo</title> </head> <body> <object id="object" classid="CLSID:2F12BFB8-137D-4DC2-9A93-634EFE5A6DFC"> <! -- The following is a pit --> <! -- classid="2F12BFB8-137D-4DC2-9A93-634EFE5A6DFC"> --> [Object not available!  Did you forget to build and register the server?]  </object> </body> </html>Copy the code

  


Next: Stay tuned…