embedding an application (in this case a terminal) within a QT application

寵の児 提交于 2019-12-03 07:53:01

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() );

You need to pass the window ID of the container to the xterm.

If you look at the example in the Qt help for QX11EmbedContainer, it just passes the window id to the QProcess. Change this to

 QProcess process(&container);
 QString executable(app.arguments()[1]);
 QStringList arguments;
 arguments << "-into" << QString::number(container.winId());
 process.start(executable, arguments);

where "-into" has been added to the arguments. From the XTerm man page:

-into windowId

Given an X window identifier (a decimal integer), xterm will reparent its top-level shell widget to that window. This is used to embed xterm within other applications.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!