在qt界面中调用matlab engine并嵌入Matlab cmd Window

本文详细介绍如何在QT环境下调用MATLAB引擎,包括配置步骤、线程操作、窗口嵌入及Windows API调用等关键操作。通过实例代码,展示了从创建项目到实现MATLAB功能的全过程。

环境:win10+QT(编译器:MSVC 2017 64-bit)+Matlab 2016a 64-bit

先上效果图:
在这里插入图片描述
在这里插入图片描述
主体思路如下(参考:https://blog.youkuaiyun.com/humanking7/article/details/86040954,做了些简化)
在这里插入图片描述

主要操作

涉及到的操作主要有:

  1. qt下启动线程操作;
  2. qt下调用matlab engine 的配置;
  3. qt嵌入外部程序的窗口;
  4. qt调用windows api;

多线程Qthread: https://blog.youkuaiyun.com/naibozhuan3744/article/details/81174681
qt下调用matlab engine的配置 http://blog.sina.com.cn/s/blog_89a45b020102vrr8.html
窗口的嵌入 https://blog.youkuaiyun.com/u013394556/article/details/78534833 https://blog.youkuaiyun.com/r5014/article/details/79286444
windows api 的调用 https://blog.youkuaiyun.com/ys_073/article/details/7770693>

代码和解释

UseMatlab.pro

#-------------------------------------------------
#
# Project created by QtCreator 2019-04-22T16:00:00
#
#-------------------------------------------------

QT       += core gui

greaterThan(QT_MAJOR_VERSION, 4): QT += widgets

TARGET = UseMatlab
TEMPLATE = app

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

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

CONFIG += c++11

SOURCES += \
        main.cpp \
        mainwindow.cpp \
    usematlabthread.cpp

HEADERS += \
        mainwindow.h \
    usematlabthread.h

FORMS += \
 
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值