PDA

View Full Version : QProcess problem: compile well but output error



jx324
29th February 2008, 18:26
Hi everyone,

I have a problem as written in title. Here are the codes:

Window::Window()
{

QGroupBox *echoGroup = new QGroupBox(tr("Anscare"));

QLabel *echoLabel = new QLabel(tr("File:"));
QPushButton *browse = new QPushButton(tr("browse.."));
QPushButton *convert = new QPushButton(tr("convert"));
echoLineEdit = new QLineEdit;
echoLineEdit->setFocus();

connect(convert, SIGNAL(clicked()),this, SLOT(runAnscare()));
connect(browse, SIGNAL(clicked()),this, SLOT(getPath()));

QGridLayout *layout = new QGridLayout;
layout->addWidget(echoGroup, 0, 0);

setLayout(layout);

setWindowTitle(tr("WinCares"));
}

void Window::runAnscare()
{
convert->setEnabled( false );

if( process )
delete process;
process = new QProcess( this );

connect( process, SIGNAL(readyReadStandardOutput()), this, SLOT(handleReadStandardOutput()));

process->start( "anscares.exe ");
}

void Window::handleReadStandardOutput()
{
QString string=echoLineEdit->text();
QFileInfo fi(string);
QString name=fi.fileName();
int i=name.size();
name.remove(i-4,4);
process->write(name.toAscii()+"\n");

}

Compile well and when "browse" button is pressed, echoLineEdit can show the path of file. But push the "convert" button, an error occurs: "something wrong with it" :mad:

Can anyone give me some hints?

Thanks.

jacek
1st March 2008, 19:37
process->start( "anscares.exe ");
Where is that file located?


But push the "convert" button, an error occurs: "something wrong with it"
Could you post the exact error message?

jx324
2nd March 2008, 01:50
The executable file was located in the debug folder. The error shows simply :"an error occurs", that's why I cannot solve it.

Anyway, thanks for your reply.

jpn
2nd March 2008, 07:39
Are you running the app via an IDE? If so, most likely the current working directory is not in debug nor release subfolder but one level up. See

QCoreApplication::applicationDirPath()
QDir::current()
Current working directory