Answer the question
In order to leave comments, you need to log in
QT 5.5. Why does the application close when the ActiveX terminates?
We have a program written in QT 5.5. In application mode it works fine, in COM server mode it works fine. But if we need to connect to an already running application via ActiveX and perform some operations (for example, reading a variable), then after the script is completed, the windows garbage collector will take the application with it. How to deal with it?
main.cpp
#include "mainwindow.h"
#include <QApplication>
#include "server.h"
#include "scales.h"
#include <QAxFactory>
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
MainWindow w;
w.show();
scales appobject(0);
QAxFactory::startServer();
QAxFactory::registerActiveObject(&appobject);
return a.exec();
}
#ifndef SCALES_H
#define SCALES_H
#include <QAxFactory>
#include "server.h"
class scales: public QObject
{
Q_OBJECT
Q_CLASSINFO("ClassID", "{2b5775cd-72c2-43da-bc3b-b0e8d1e1cdf2}")
Q_CLASSINFO("InterfaceID", "{2ce1761e-07a3-415c-bd11-b0e8d1e1cdf2}")
Q_CLASSINFO("EventID","{52e8e1eb-ccee-4ae6-9b86-c82d11f606d1}")
Q_PROPERTY(QString num READ num)
public:
scales(QObject *parent = 0);
QString num() { return "greate";}
};
#endif // SCALES_H
#include "scales.h"
scales::scales(QObject *parent): QObject(parent)
{
}
QAXFACTORY_BEGIN("{edd3e836-f537-4c6f-be7d-6014c155cc7a}", "{b7da3de8-83bb-4bbe-9ab7-99a05819e201}")
QAXCLASS(scales)
QAXFACTORY_END()
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question