QX11EmbedContainer和QProcess问题
我一直在尝试将 QX11EmbedContainer 放入我的应用程序中,并且我需要在其中启动一个终端(因为使用 konsolepart 我几乎什么也做不了)。
QX11EmbedContainer* container = new QX11EmbedContainer(this); // with or without "this" I got the same result
container->show();
QProcess process(container);
QString executable("xterm -into ");
QStringList arguments;
arguments << QString::number(container->winId());
process.start(executable, arguments);
编译顺利,但我收到了这条消息:
QProcess: Destroyed while process is still running.
我看不到容器,建议?????? 谢谢
I've been trying to put a QX11EmbedContainer in my app, and I need to start a terminal within it (because with konsolepart I can practically do nothing).
QX11EmbedContainer* container = new QX11EmbedContainer(this); // with or without "this" I got the same result
container->show();
QProcess process(container);
QString executable("xterm -into ");
QStringList arguments;
arguments << QString::number(container->winId());
process.start(executable, arguments);
compilation goes fine,but I got this message:
QProcess: Destroyed while process is still running.
and I'm not able to see the container, suggestions?????? Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
QProcess
在堆栈上分配,一旦超出范围就会被删除。 这很可能发生在“xterm”子进程退出之前(因此是输出)。尝试在堆中分配 QProcess:
您可以通过三种方式删除 QProcess:
不执行任何操作。 让
QX11EmbedContainer
删除它。 它是QX11EmbedContainer
的子级,并且会在删除QX11EmbedContainer
时被删除。将
finished()
信号连接到其自己的deleteLater()
槽。connect( process, SIGNAL(finished(int,QProcess::ExitStatus)), process, SLOT(deleteLater()) );
通过保留指向它的指针来删除它并删除该指针稍后。
作为额外说明,我对 QProcess::start() 的第一个参数表示怀疑。 它应该是可执行文件的路径,并且应将更多参数添加到 QStringlist 中。
The
QProcess
is allocated on the stack and will deleted as soon as it goes out of scope. This is likely to happen before the the "xterm" child process quits (hence the output).Try allocating the QProcess in the heap instead:
You can delete the QProcess in three ways:
Do nothing. Let the
QX11EmbedContainer
delete it. It is a child of theQX11EmbedContainer
and will be deleted when theQX11EmbedContainer
is deleted.Hook up the
finished()
signal to its owndeleteLater()
slot.connect( process, SIGNAL(finished(int,QProcess::ExitStatus)), process, SLOT(deleteLater()) );
Delete it yourself by retaining a pointer to it and delete that pointer later.
As an extra note, I'm suspicious of the first parameter to
QProcess::start()
. It should be the path to your executable and further arguments should be added to theQStringlist
.