当前位置:网站首页>Qt嵌入子Qt程序窗口到当前程序
Qt嵌入子Qt程序窗口到当前程序
2022-06-30 11:03:00 【windSnowLi】
子程序主要代码
#include "ChildWidgets.h"
#include <QtWidgets/QApplication>
#include <QWindow>
#include <iostream>
#include <QMessageBox>
#include <thread>
int main(int argc, char* argv[])
{
QApplication a(argc, argv);
ChildWidgets w;
w.show();
w.createWinId();
// 输出
std::cerr << w.winId() << std::endl;
return a.exec();
}
主程序主要代码
InWidgets::InWidgets(QWidget* parent)
: QMainWindow(parent)
{
this->resize(600, 400);
// 获取程序所在路径
QString path = QCoreApplication::applicationDirPath();
path += "/ChildWidgets.exe";
process = new QProcess(this);
connect(process, &QProcess::readyReadStandardError, [&]() {
quint64 winId = process->readAllStandardError().toLongLong();
QWindow* childWin = QWindow::fromWinId(winId);
if (childWin)
{
QWidget* widget = QWidget::createWindowContainer(childWin);
this->setCentralWidget(widget);
}
});
process->start(path);
// 子窗口嵌入当前窗口
process->setParent(this);
}
结果

地址:https://download.csdn.net/download/qq_44575789/85800705
边栏推荐
- 10 reasons for system performance failure
- LVGL 8.2 re-coloring
- [untitled]
- Oceanbase installation Yum source configuration error and Solutions
- LVGL 8.2 Image
- LeetCode Algorithm 86. Separate linked list
- Record the memory leak of viewpager + recyclerview once
- LVGL 8.2 Checkboxes as radio buttons
- 第一届中国数字藏品大会即将召开
- Go language defer
猜你喜欢

Kongsong (ICT Institute) - cloud security capacity building and trend in the digital age

暑假学习记录

CVPR 2022 | 大幅减少零样本学习所需人工标注,马普所和北邮提出富含视觉信息的类别语义嵌入...

从开源项目探讨“FPGA挖矿”的本质

对象映射 - Mapping.Mapster
![[understanding of opportunity -34]: fate is within the light cone](/img/3e/9f5630ba382df7f7ce00705445cef8.jpg)
[understanding of opportunity -34]: fate is within the light cone

语音识别-基础(一):简介【语音转文本】

Wireguard simple configuration

记一次ViewPager + RecyclerView的内存泄漏

ESP32-C3入门教程 问题篇⑨——Core 0 panic‘ed (Load access fault). Exception was unhandled. vfprintf.c:1528
随机推荐
8 lines of code to achieve quick sorting, easy to understand illustrations!
考研这些“不靠谱”的经验有多害人?
Oceanbase installation Yum source configuration error and Solutions
LeetCode Algorithm 86. Separate linked list
SQL必需掌握的100个重要知识点:创建和操纵表
脚本中如何'优雅'避免MySQL登录提示信息
语音信号处理-基础(五):傅立叶变换
SQL必需掌握的100个重要知识点:插入数据
The life, working principle and application of electrochemical oxygen sensor
19年来最艰难的618,徐雷表达三个谢意
100 important knowledge points that SQL must master: creating and manipulating tables
When does the database need to use the index [Hangzhou multi surveyors] [Hangzhou multi surveyors _ Wang Sir]
iptables目标TPROXY
Oracle NetSuite 助力 TCM Bio,洞悉数据变化,让业务发展更灵活
datax - 艰难debug路
Create - configure factory
基于HAL库的LED驱动库
CVPR 2022 | 大幅减少零样本学习所需人工标注,马普所和北邮提出富含视觉信息的类别语义嵌入...
线代(高斯消元法、线性基)
数据库 级联操作