找回密码
 立即注册
收起左侧

QT5.7版本使用activeX出现重定义

1
回复
7067
查看
[复制链接]
累计签到:3 天
连续签到:1 天
来源: 2017-11-7 21:27:24 显示全部楼层 |阅读模式
1Qter豆
本帖最后由 zhkmxx930 于 2017-11-7 21:27 编辑

QT套件 5.7.1 + MinGW32 5.3.0版本

.pro文件配置如下
  1. #-------------------------------------------------
  2. #
  3. # Project created by QtCreator 2017-11-07T21:02:30
  4. #
  5. #-------------------------------------------------

  6. QT       += core gui
  7. QT      += axcontainer
  8. greaterThan(QT_MAJOR_VERSION, 4): QT += widgets

  9. TARGET = testActivX
  10. TEMPLATE = app

  11. # The following define makes your compiler emit warnings if you use
  12. # any feature of Qt which as been marked as deprecated (the exact warnings
  13. # depend on your compiler). Please consult the documentation of the
  14. # deprecated API in order to know how to port your code away from it.
  15. DEFINES += QT_DEPRECATED_WARNINGS

  16. # You can also make your code fail to compile if you use deprecated APIs.
  17. # In order to do so, uncomment the following line.
  18. # You can also select to disable deprecated APIs only up to a certain version of Qt.
  19. #DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000    # disables all the APIs deprecated before Qt 6.0.0


  20. SOURCES += main.cpp\
  21.         mainwindow.cpp

  22. HEADERS  += mainwindow.h

  23. FORMS    += mainwindow.ui
复制代码


在main.cpp中直接调用QAxWidget
  1. #include "mainwindow.h"
  2. #include <QApplication>
  3. #include <QAxWidget>
  4. #include <QDebug>

  5. int main(int argc, char *argv[])
  6. {
  7.     QApplication a(argc, argv);
  8.     QAxWidget *motor =new QAxWidget(0,0);
  9.     motor->resize(600,500);
  10.     qDebug()<<"before set control code";
  11.     motor->setControl(QString::fromUtf8("{7EEBDE39-6447-41EC-89D8-94A754092050}"));
  12.     motor->setWindowTitle("the motor of APT");
  13.     const int SN=71864678;
  14.     QVariant qsn(SN);
  15.     qDebug()<<qsn;
  16.     motor->setProperty("HWSerialNum",qsn);
  17.     qDebug()<<motor->property("HWSerialNum");
  18.     qDebug()<<"after set control code";
  19.     motor->dynamicCall("StartCtrl()");
  20.     motor->show();

  21.     return a.exec();
  22. }
复制代码
结果编译出现错误

请问是什么原因

附件: 您需要 登录 才可以下载或查看,没有帐号?立即注册
回复

使用道具 举报

累计签到:3 天
连续签到:1 天
2017-11-7 21:27:25 显示全部楼层
只要new QAxWidget的对象,就会出现这个错误
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

公告
可以关注我们的微信公众号yafeilinux_friends获取最新动态,或者加入QQ会员群进行交流:190741849、186601429(已满) 我知道了