2008-11-20 55 views
6

我正在編寫一個QT應用程序,我需要在QDialog中嵌入一個終端(我們說,xterm),就像一些KDE應用程序一樣(請參閱kdevelop/kate/...)。在QT應用程序中嵌入應用程序(本例中爲終端)

我一直在試圖用: - QX11EmbedContainer放到我了QDialog 的QLayout - QProcess中的我想excecute

我預計QProcess中的QX11EmbedContainer內運行的程序,但它不工作。

問題是我不能把xterm放到QX11EmbedContainer中,我得到的唯一的東西是一個xterm窗口(不幸與我的QDialog分開)。 有沒有人得到同樣的問題?

回答

3

對不起,我試過你的解決方案之前發佈哦這個網站,它不工作。 我已經解決切換到kde庫,並使用這些進口和驗證碼

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

您需要將容器的窗口ID傳遞給xterm。

如果您查看QX11EmbedContainer的Qt幫助中的示例,它只是將窗口ID傳遞給QProcess。將其更改爲

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

其中「-into」已添加到參數中。從Xterm手冊頁:

-INTO WINDOWID

給定一個X窗口標識符(十進制整數)的xterm 將重新設置父級的頂級shell 部件到該窗口。這用於 在其他應用程序中嵌入xterm。