guide to use Active Qt to create ocx file for windowse.
-
Hi.I want to create OCX ( com object ). when I read this article : http://doc.qt.io/qt-5/activeqt-index.html I found there are two type of active qt.
QAxContainer and QAxServer.
My purpose is to make OCX file .I have a TCP class make client to connect to server and read data and write data in LAN network.I want this OCX can attach to any application. (like Delphi or other program language).
This class functions are: connect to server , read data from server and send it to application by output and write data on network by getting data from input.I wand to change this class to OCX file to attach to any applications. I do not know which one is select? (QAxContainer and QAxServer.)
-
Hi
As far as I know, u want the QAxServer
I have not seen many samples but this one explains a bit
http://www.bogotobogo.com/cplusplus/files/c-gui-programming-with-qt-4-2ndedition.pdf
Using ActiveX on Windows
They make a small com object and show in browser.Its almost the same as the
http://doc.qt.io/qt-5/activeqt-activeqt-simple-example.html -
@mrjj thank you for answer. I read that book but I did not get anything.
I do like this site and make an example: http://nickguthrie.com/embedd_gui/src/qt-everywhere-opensource-src-4.8.4/doc/html/activeqt-server.html
1- create widget application. (first made by console app but the Qt creator alert show it is not good in console app so I create widget app)2- in .pro :
#------------------------------------------------- # # Project created by QtCreator 2016-08-20T12:52:04 # #------------------------------------------------- QT += core gui greaterThan(QT_MAJOR_VERSION, 4): QT += widgets TARGET = Test2ActiveXServer TEMPLATE = app SOURCES += main.cpp\ mainwindow.cpp \ test.cpp HEADERS += mainwindow.h \ test.h FORMS += mainwindow.ui #this is make QAXserver CONFIG += axserver RC_FILE = qaxserver.rc
in main.cpp:
#include "mainwindow.h" #include <QApplication> #include <QAxFactory> int main(int argc, char *argv[]) { QApplication a(argc, argv); if ( !QAxFactory::isServer() ) { MainWindow w; w.show(); } return a.exec(); }
then create a class and its name is test.
test.h:#ifndef TEST_H #define TEST_H #include <QObject> #include <QAxBindable> #include <QWidget> #include <QAxFactory> class test : public QObject , public QAxBindable { Q_OBJECT Q_PROPERTY( int value READ value WRITE setValue ) QAXFACTORY_BEGIN("{3304a730-4230-4a82-ab61-334a2e93c803}", "{23667206-d900-4f1a-a14f-30397fa5adc7}") QAXCLASS(MyWidget) QAXCLASS(MyWidget2) QAXTYPE(MySubType) QAXFACTORY_END() public: explicit test(QObject *parent = 0); int value() const; signals: void valueChange ( int a); public slots: void setValue (int a); private: int *val; }; #endif // TEST_H
and test.cpp :
#include "test.h" test::test(QObject *parent) : QObject(parent) { } int test::value() const { return val; } void test::setValue(int a) { val=a; emit valueChange(val); }
after that I dont know what am I do?
when run qmake just the qmake file create. when I build the project it shows me this error::-1: error: dependent '..\Test2ActiveXServer\qaxserver.rc' does not exist.
in that doc it says : "To build the ActiveX server executable run qmake to generate the makefile, and use your compiler's make tool as for any other Qt application. The make process will also register the controls in the system registry by calling the resulting executable with the -regserver command line option." . I don't understand it.
My question is :
Is that project is Active x server?
How to test it?
what am I do know?
How does it work?