将应用程序(在这种情况下为终端)嵌入到QT应用程序中 [英] embedding an application (in this case a terminal) within a QT application

查看:62
本文介绍了将应用程序(在这种情况下为终端)嵌入到QT应用程序中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在编写QT应用程序,并且需要像某些KDE应用程序一样将终端(例如xterm)嵌入QDialog中(请参阅kdevelop/kate/...).

I am writing a QT application and I need to embed a terminal (we say,xterm) within a QDialog, like some KDE application (see kdevelop/kate/...).

我一直在尝试:-QX11EmbedContainer放在我的QDialog的QLayout中-我要执行的程序的QProcess

I've been trying with: - QX11EmbedContainer placed into the QLayout of my QDialog - QProcess for the program I want to excecute

我希望QProcess在QX11EmbedContainer中运行,但不能正常工作.

I expect the QProcess running within the QX11EmbedContainer, but it does not work.

问题是我无法将xterm放入QX11EmbedContainer中,唯一获得的是xterm窗口(不幸的是与QDialog分开了).有人遇到同样的问题吗?

The problem is that I can't put the xterm into the QX11EmbedContainer, the only thing I obtain is an xterm window (unfortunately separated from my QDialog). Does anybody got the same problem?

推荐答案

对不起,我已经在发布哦这个网站之前尝试了您的解决方案,它不起作用.我已经解决了切换到kdelibs并使用这些导入和这段代码的问题

Sorry, I've tried your solution before posting oh this site and it does not work. I've solved switching to kdelibs and using those imports and this code

#include <kparts/part.h>
#include <assert.h>
#include <kde_terminal_interface.h>
#include <kpluginfactory.h>
#include <klibloader.h>


KLibFactory* factory = KLibLoader::self()->factory( "libkonsolepart" );
KParts::Part* p = static_cast<KParts::Part*>(factory->create( this,"tralala",         
QStringList() << "dio") );

assert(p);
setCentralWidget( p->widget() );
TerminalInterface *t = qobject_cast<TerminalInterface*>(p);
t->showShellInDir( QDir::home().path() );

这篇关于将应用程序(在这种情况下为终端)嵌入到QT应用程序中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆