QX11EmbedWidget and QX11EmbedContainer

北城余情 提交于 2019-12-21 05:34:28

问题


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;
}

回答1:


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



来源:https://stackoverflow.com/questions/1102658/qx11embedwidget-and-qx11embedcontainer

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