Search code examples
qtqx11embedcontainer

QX11EmbedWidget and QX11EmbedContainer


Can one place an arbitrary program (firefox, openoffice, etc...) in a QX11EmbedContainer? The fllowing seems, to work

int main(int argc, char *argv[])
{
    QApplication app(argc, argv);

    QX11EmbedContainer container;
    container.show();

    QProcess * process = new QProcess(&container);
    QString executable("xterm");
    QStringList arguments;
    arguments << "-into";
    arguments << QString::number(container.winId());
    process->start(executable, arguments);

    int status = app.exec();
    process->close();
    return status;
}

but the next snippet launches a new window, not what I want

int main(int argc, char *argv[])
{
  QApplication app(argc, argv);

  QX11EmbedContainer container;
  container.show();

  QProcess * process = new QProcess(&container);
  QString executable("konsole");
  process->start(executable);

  int status = app.exec();
  process->close();
  return status;
}

Solution

  • The first example work because xterm is able to reparent its top level widget (an X11 window). You tell it to do so with the argument -into <WinId>.

    I don't know if Konsole can do that, i don't use it and the man page doesn't seem to talk about this.

    But that doesn't mean it is not doable, the X Window system is very flexible and anyone can reparent another window (that's how windows managers add decorations to windows).

    Take a look at man 3 XReparentWindow ;-)