views:

56

answers:

0

Hello.

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?

EDIT: SOLVED

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);