PDA

Archiv verlassen und diese Seite im Standarddesign anzeigen : [Qt] QProcess startet nicht?



tuxipuxi
27-04-2003, 18:17
Hallo,

tut mir wirklich leid das ich fragen muss.. aber nach tausenden qDebug()'s und co komme ich nicht weiter. ich moechte ein servicemenu fuer dne konqueror schreiben, ein splitter.
es geht jetzt nicht um das .desktop sondern um qsplit an sich.

ich habe mit qdebug ueberprueft ob das kommando was der QProcess ausfuehren soll richtig ist, das ist es. nur ich habe das gefuehl das er ueberhaupt nicht startet.

hier mal header und impl.:

qsplit.h:


#ifndef QSPLIT_H
#define QSPLIT_H

#include <qvbox.h>

class QCheckBox;
class QFileInfo;
class QPushButton;
class QLineEdit;
class QLabel;
class QHBox;
class QProcess;


class QSplit : public QVBox {
Q_OBJECT

public:

QSplit( const char* fname, QWidget* parent=0, const char* name=0 );

private slots:

void split();


private:

QFileInfo *fileInfo;
QLineEdit *Size;
QCheckBox *floppy,*minicd,*cdrom;
QLabel *fileSize,*Info,*fileName,*otherSize;
QHBox *preSelectedB;
QPushButton *splitButton;
QProcess *splitP;
const char *filename;




};

#endif //QSPLIT_H


und, die wohl weitaus interessantere, split.cpp:




#include <qlineedit.h>
#include <qpushbutton.h>
#include <qfileinfo.h>
#include <qcheckbox.h>
#include <qstring.h>
#include <qlabel.h>
#include <qhbox.h>
#include <qprocess.h>

#include "qsplit.h"

QSplit::QSplit( const char* fname, QWidget* parent, const char* name )
:QVBox( parent, name ), filename( fname ) {


this->setCaption( "QSplit 0.1 -- Konqueror Service" );
this->setSpacing( 10 );

fileInfo = new QFileInfo( QString::fromLatin1( fname ) );

fileName = new QLabel( "File Name: " + fileInfo->fileName() , this );
fileSize = new QLabel( "File Size: " + QString::number( fileInfo->size() ), this );
Info = new QLabel( "Specify the Size of the Pieces......", this );

preSelectedB= new QHBox( this );

floppy = new QCheckBox( "Floppy(1.44MB)" , preSelectedB );
cdrom = new QCheckBox( "Cdrom(650MB)", preSelectedB );

otherSize = new QLabel( "Other Size( in Mb ): ", this );

Size = new QLineEdit( this );

splitButton = new QPushButton( "Split it!" , this );

connect( splitButton, SIGNAL(released() ), this, SLOT( split() ) );


}

void QSplit::split() {


splitP = new QProcess( this );
splitP->setWorkingDirectory( fileInfo->dirPath() );

if( floppy->isChecked() ) {

QString cmd = "split -b1440k " + QString::fromLatin1(filename);
splitP->addArgument( cmd );
splitP->start();
connect( splitP, SIGNAL(readyReadStdout() ), this, SLOT( readstd() ) );
connect( splitP, SIGNAL(readyReadStderr() ), this, SLOT( readerr() ) );
connect( splitP, SIGNAL(processExited() ) , this, SLOT( isexit() ) );
}

}



sieht da einer n denkfehler?

danke im vorraus,

tuxipuxi

anda_skoa
27-04-2003, 18:28
Probier es so



QStringList cmd;
cmd.append("split");
cmd.append("-b1440k");
cmd.append(QFile::encodeName(filename));

splitP->setArguments(cmd);
splitP->start();


Wenn du stdout bzw stderr bekommen willst, solltest du auch die entsprechen Flags mit setCommunication setzen.

Btw, irgend ein spezieller Grund, warum du beim Button released() anstatt clicked() benutzt?

Ciao,
_

tuxipuxi
27-04-2003, 18:42
wow.. :D danke.. das funktioniert :).

vielen dank :)

gruss tuxipuxi

anda_skoa
27-04-2003, 18:50
Fein :)

Bitte sieh dir für die Dateinamen die Funktionen QFile::encodeName und ::decodeName an.
QString::fromLatin1 sieht nach Abhängigkeit aus.

Ciao,
_