hi friends,
please help 
i create a code to embed gtk window to my Qt app ..
mainwindow.cpp
procc2
->setProcessChannelMode
(QProcess::MergedChannels);
connect(procc2, SIGNAL(readyReadStandardOutput()), this, SLOT(readFromStdout2()));
procc2 = new QProcess();
procc2->setProcessChannelMode(QProcess::MergedChannels);
connect(procc2, SIGNAL(readyReadStandardOutput()), this, SLOT(readFromStdout2()));
To copy to clipboard, switch view to plain text mode
this is a timer function calling every 400 milli sec
MainWindow::timeout{
if(...)
{
if(procc2
->state
() != QProcess::Running) {
procc2->start(program4, arguments2);
}
}
MainWindow::timeout{
if(...)
{
QString program4 = "./gtk_demo2";
QStringList arguments2;
if(procc2->state() != QProcess::Running)
{
procc2->start(program4, arguments2);
}
}
To copy to clipboard, switch view to plain text mode
readfromstdout() function will call the function to embed the process
MainWindow::readFromStdout2()
{
int j = 0;
bool ok;
printf("in singal fin\n");
out = procc2->readAllStandardOutput();
j = out.toInt(&ok, 16);
printf("j =%d\n",j);
if(j == 1)
printf("device not connected\n");
else{
printf("the device connected\n");
embed();
}
}
MainWindow::readFromStdout2()
{
int j = 0;
bool ok;
QString out;
printf("in singal fin\n");
out = procc2->readAllStandardOutput();
j = out.toInt(&ok, 16);
printf("j =%d\n",j);
if(j == 1)
printf("device not connected\n");
else{
printf("the device connected\n");
embed();
}
}
To copy to clipboard, switch view to plain text mode
this is my code and the function embed() will embed the "gtk_demo" window if it returns 0 or anything ...
the problem is on first time if i spawn the signal "readyReadStandardOutput()"
is not emitted and readFromStdout2() slot is not called .
i closed the spawned gtk application "gtk_demo" and as i put the procc in loop again it spawn "gtk_demo" its emitting "readyReadStandardOutput()" and embedding perfectly ... why??
i changed gtk application to a Qt application and try the same thing its worked in the first attempt ... 
please help me ...
Bookmarks