将 mscomm ActiveX 与 Qt 结合使用

发布于 2024-09-24 18:53:38 字数 351 浏览 0 评论 0原文

我知道由于现有的新替代方案,这个问题可能看起来很奇怪,但相信我,这是有原因的。

我想使用mscomm active X控件通过串口与Qt进行通信。 是的,我知道有 QextSerialPort、QSerialDevice 和很多关于如何编写串行通信代码的示例。但由于我遇到问题,我想测试 mscomm。

我知道Qt有一个使用ActiveX控件的系统,但我找不到任何关于如何使用它们的明确信息(我不明白qt官方文档对此的理解)。

Visual C++ 6 有一个 mscomm.h 和 mscomm.cpp,我认为它们实现了 active x 接口,但到处都有大量的 microsoft mfc 宏和依赖项。

有什么线索吗?

I know this question may seem odd due to new existing alternatives, but trust me there's a reason.

I would like to use the mscomm active X control to communicate through serial port with Qt.
Yes, I know there's QextSerialPort, QSerialDevice and a lot of examples about how to write serial communication code. But due a problems I have I would like to test mscomm.

I know Qt has a system to use ActiveX controls, but I cannot find any clear information about how to use them (I don't understand the qt official doc about this).

Visual C++ 6 has a mscomm.h and mscomm.cpp which I think implements the active x interface, but is plenty of microsoft mfc macros and dependencies everywhere.

Any clue?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

余生一个溪 2024-10-01 18:53:38

好吧,看来我实现了。

您必须使用 QAxObject 来包装要执行的 activeX。为此,您需要知道 CLSID,在我的例子中:

  QAxObject* activex = new QAxObject("648A5600-2C6E-101B-82B6-000000000014");

然后您只需要使用dynamicCall(QString,QVariant)来调用ActiveX控件具有的任何成员。要生成所有可用方法的列表,请使用:

  QString doc = activex->generateDocumentation();

这太棒了,您将获得一个 html 文档,其中包含所有可用的成员、属性和示例,这些示例解释了如何使用它们(Qt 文档告诉您可以使用 dumpdoc 来生成相同的信息)

以下是如何打开端口(端口号 4)的示例:

  QAxObject* activex = new QAxObject("648A5600-2C6E-101B-82B6-000000000014");
  activex->dynamicCall("SetCommPort(int)", 4);
  activex->dynamicCall("SetPortOpen(bool)", true);

Ok, seems I achieved it.

You must use QAxObject to wrap the activeX you want to execute. To do so you need to know the CLSID, in my case :

  QAxObject* activex = new QAxObject("648A5600-2C6E-101B-82B6-000000000014");

Then you only need to use dynamicCall( QString, QVariant ) to call any of the members the ActiveX control has. To generate a list of all available methods use:

  QString doc = activex->generateDocumentation();

This is wonderful, you get an html document with all available members, properties and examples which explain how to use them (Qt Documentation tell you can use dumpdoc to generate the same info)

Here an example on how to open a port (port number 4):

  QAxObject* activex = new QAxObject("648A5600-2C6E-101B-82B6-000000000014");
  activex->dynamicCall("SetCommPort(int)", 4);
  activex->dynamicCall("SetPortOpen(bool)", true);
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文