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[])
{
Program *mystarter = new Program();
a.connect(okButton, SIGNAL(clicked()), mystarter, SLOT(startprocess()));
okButton->setMinimumWidth(150);
okButton->show();
return a.exec();
}
#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();
}
To copy to clipboard, switch view to plain text mode
#ifndef PROGRAM_H
#define PROGRAM_H
#include <QObject>
#include <QProcess>
{
Q_OBJECT
public:
explicit Program
(QObject *parent
= 0);
public slots:
void startprocess();
};
#endif
#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
To copy to clipboard, switch view to plain text mode
#include "program.h"
#include <QString>
#include <QStringList>
{}
void Program::startprocess()
{
list << "a" << "-t7z" << "mx9" << "/home/user/Desktop/Desktop.7z" << "/home/user/Desktop/file1.pdf" << "/home/user/Desktop/file2.doc";
myprocess.start("7z", list);
}
#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);
}
To copy to clipboard, switch view to plain text mode
Bookmarks