QX11EmbedContainer and QProcess issue

I am trying to put a QX11EmbedContainer in my application and I need to start a terminal in it (because with konsolepart I can hardly do anything).

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 is going fine, but I got this message:

QProcess: Destroyed while process is still running.

      

and i can't see the container, suggestions ?????? Thanks to

+1


source to share


1 answer


QProcess

is allocated on the stack and removed as soon as it goes out of scope. This will likely happen before the xterm child process exits (hence exit).

Try assigning QProcess on the heap:

QProcess * process = new QProcess(container);
...
process->start(executable, arguments);

      

You can uninstall QProcess in three ways:



  • Do not do anything. Let QX11EmbedContainer

    him remove it. This is a child element QX11EmbedContainer

    and will be removed when removed QX11EmbedContainer

    .

  • Connect the signal finished()

    to your slot deleteLater()

    .

    connect( process, SIGNAL(finished(int,QProcess::ExitStatus)), process, SLOT(deleteLater()) );

  • Delete it yourself, keeping a pointer to it and deleting that pointer later.

As a side note, I am suspicious of the first parameter QProcess::start()

. This should be the path to your executable and further arguments should be added to QStringlist

.

QProcess * process = new QProcess(container);
QString executable("xterm"); // perhaps try "/usr/X11/bin/xterm"
QStringList arguments;
arguments << "-into";
arguments << QString::number(container->winId());
proces->start(executable, arguments);

      

+2


source







All Articles