Qt开发Activex笔记(一):环境搭建、基础开发流程和演示Demo
source link: https://segmentfault.com/a/1190000039205429
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
若该文为原创文章,转载请注明原文出处
本文章博客地址: https://blog.csdn.net/qq21497936/article/details/113773009
长期持续带来更多项目与技术分享,咨询请加QQ:21497936、微信:yangsir198808
红胖子(红模仿)的博文大全:开发技术集合(包含Qt实用技术、树莓派、三维、OpenCV、OpenGL、ffmpeg、OSG、单片机、软硬结合等等)持续更新中…(点击传送门)
Qt开发专栏:开发技术
上一篇:无
下一篇:敬请期待...
前言
使用C#开发动画,绘图性能跟不上,更换方案使用Qt开发Qt的控件制作成OCX以供C#调用,而activex则是ocx的更高级形式。
QtCreator是没有Active控件项目的,所有需要使用VS,笔者使用VS2019开发。
准备工作
Qt5.15.2 + VS2019 + vs tools,搭建基础开发环境不再赘述。
开发第一个Qt Activex:Hello world
步骤一:新建Qt ActiveQt Server项目
步骤二:拖一个QLabel,输入”Hello world”
步骤三:生成出现错误“MSB3073”
需要使用管理员权限打开VS2019软件。
步骤四:生成release和debug版本
步骤五:注册activex控件
运行之前先要注册,使用Qt下自带的idc注册一下。
idc -regserver activeHelloWorldDemo.dll
步骤六:调用activeQt控件
查看一下,打开注册表并搜索一下,确认clsid,如下图:
创建一个html,然后输入如下内容:
<html> <head> <title>activeQtDemo</title> </head> <body> <object id="object" classid="CLSID:2F12BFB8-137D-4DC2-9A93-634EFE5A6DFC"> <!-- 以下为入坑了 --> <!-- classid="2F12BFB8-137D-4DC2-9A93-634EFE5A6DFC"> --> [Object not available! Did you forget to build and register the server?] </object> </body> </html>
使用IE运行,active是微软特有的,其他浏览器不支持,如下图:
入坑
入坑一:调用控件失败
问题
原因
因为classid的格式错误
解决
<html> <head> <title>activeQtDemo</title> </head> <body> <object id="object" classid="CLSID:2F12BFB8-137D-4DC2-9A93-634EFE5A6DFC"> <!-- 以下为入坑了 --> <!-- classid="2F12BFB8-137D-4DC2-9A93-634EFE5A6DFC"> --> [Object not available! Did you forget to build and register the server?] </object> </body> </html>
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK