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

后端 未结 2 1107
小蘑菇
小蘑菇 2021-02-09 18:20

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/...).

I\'ve been trying with:

2条回答
  •  温柔的废话
    2021-02-09 18:27

    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.

提交回复
热议问题