mr_kazoodle
3rd February 2011, 10:35
Hi,
I took the command to create a simple archive using the terminal and put every argument in a QStringlist, but the result is that the program creates an archive called mx9.7z in the folder where the program is located.
Why doesn't this example program do the same thing as the same command entered in the terminal?
(7z a -t7z mx9 /home/user/Desktop/Desktop.7z /home/user/Desktop/file1.pdf /home/user/Desktop/file2.doc)
#include <QtGui/QApplication>
#include <QPushButton>
#include "program.h"
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
QPushButton *okButton = new QPushButton("OK");
Program *mystarter = new Program();
a.connect(okButton, SIGNAL(clicked()), mystarter, SLOT(startprocess()));
okButton->setMinimumWidth(150);
okButton->show();
return a.exec();
}
#ifndef PROGRAM_H
#define PROGRAM_H
#include <QObject>
#include <QProcess>
class Program : public QObject
{
Q_OBJECT
public:
QProcess myprocess;
explicit Program(QObject *parent = 0);
public slots:
void startprocess();
};
#endif
#include "program.h"
#include <QString>
#include <QStringList>
Program::Program(QObject *parent) : QObject(parent)
{}
void Program::startprocess()
{
QStringList list;
list << "a" << "-t7z" << "mx9" << "/home/user/Desktop/Desktop.7z" << "/home/user/Desktop/file1.pdf" << "/home/user/Desktop/file2.doc";
myprocess.start("7z", list);
}
I took the command to create a simple archive using the terminal and put every argument in a QStringlist, but the result is that the program creates an archive called mx9.7z in the folder where the program is located.
Why doesn't this example program do the same thing as the same command entered in the terminal?
(7z a -t7z mx9 /home/user/Desktop/Desktop.7z /home/user/Desktop/file1.pdf /home/user/Desktop/file2.doc)
#include <QtGui/QApplication>
#include <QPushButton>
#include "program.h"
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
QPushButton *okButton = new QPushButton("OK");
Program *mystarter = new Program();
a.connect(okButton, SIGNAL(clicked()), mystarter, SLOT(startprocess()));
okButton->setMinimumWidth(150);
okButton->show();
return a.exec();
}
#ifndef PROGRAM_H
#define PROGRAM_H
#include <QObject>
#include <QProcess>
class Program : public QObject
{
Q_OBJECT
public:
QProcess myprocess;
explicit Program(QObject *parent = 0);
public slots:
void startprocess();
};
#endif
#include "program.h"
#include <QString>
#include <QStringList>
Program::Program(QObject *parent) : QObject(parent)
{}
void Program::startprocess()
{
QStringList list;
list << "a" << "-t7z" << "mx9" << "/home/user/Desktop/Desktop.7z" << "/home/user/Desktop/file1.pdf" << "/home/user/Desktop/file2.doc";
myprocess.start("7z", list);
}