At final i have
comicview.h
#ifndef COMICVIEW_H
#define COMICVIEW_H
#include "unzip.h"
#include <QMainWindow>
#include <QProcess>
#include <QFileDialog>
#include <QMessageBox>
#include <QString>
namespace Ui {
class ComicView;
}
{
Q_OBJECT
public:
explicit ComicView
(QWidget *parent
= 0);
~ComicView();
private slots:
void on_actionExit_triggered();
void on_actionOpen_triggered();
signals:
void signal_unzip_file
(QString filename
);
private:
Ui::ComicView *ui;
UnZip m_unzip;
};
#endif // COMICVIEW_H
#ifndef COMICVIEW_H
#define COMICVIEW_H
#include "unzip.h"
#include <QMainWindow>
#include <QProcess>
#include <QFileDialog>
#include <QMessageBox>
#include <QString>
namespace Ui {
class ComicView;
}
class ComicView : public QMainWindow
{
Q_OBJECT
public:
explicit ComicView(QWidget *parent = 0);
~ComicView();
private slots:
void on_actionExit_triggered();
void on_actionOpen_triggered();
signals:
void signal_unzip_file(QString filename);
private:
Ui::ComicView *ui;
UnZip m_unzip;
};
#endif // COMICVIEW_H
To copy to clipboard, switch view to plain text mode
comicview.cpp
#include "comicview.h"
#include "ui_comicview.h"
ComicView
::ComicView(QWidget *parent
) : ui(new Ui::ComicView)
{
ui->setupUi(this);
connect( ui->actionExit, SIGNAL(triggered()), this, SLOT(close()) );
connect( ui->actionOpen, SIGNAL(triggered()), this, SLOT(open()) );
connect(this,
SIGNAL(signal_unzip_file
(QString)),
&m_unzip,
SLOT(unzipfile
(QString)));
}
ComicView::~ComicView()
{
delete ui;
}
void ComicView::on_actionExit_triggered()
{
statusBar()->showMessage(tr("exit"), 2000);
}
void ComicView::on_actionOpen_triggered()
{
this, tr("Open File"),"", tr("Files (*.cbz)"));
if (fileName != "") {
QMessageBox::critical(this, tr
("Error"), tr
("Could not open file"));
return;
}
}
emit signal_unzip_file(fileName);
}
#include "comicview.h"
#include "ui_comicview.h"
ComicView::ComicView(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::ComicView)
{
ui->setupUi(this);
connect( ui->actionExit, SIGNAL(triggered()), this, SLOT(close()) );
connect( ui->actionOpen, SIGNAL(triggered()), this, SLOT(open()) );
connect(this, SIGNAL(signal_unzip_file(QString)), &m_unzip, SLOT(unzipfile(QString)));
}
ComicView::~ComicView()
{
delete ui;
}
void ComicView::on_actionExit_triggered()
{
statusBar()->showMessage(tr("exit"), 2000);
}
void ComicView::on_actionOpen_triggered()
{
QString fileName = QFileDialog::getOpenFileName(
this, tr("Open File"),"", tr("Files (*.cbz)"));
if (fileName != "") {
QFile file(fileName);
if (!file.open(QIODevice::ReadOnly)) {
QMessageBox::critical(this, tr("Error"), tr("Could not open file"));
return;
}
}
emit signal_unzip_file(fileName);
}
To copy to clipboard, switch view to plain text mode
unzip.h
#ifndef UNZIP_H
#define UNZIP_H
#include <QProcess>
#include <QObject>
#include <QString>
{
Q_OBJECT
public:
explicit UnZip
(QObject *parent
= 0);
public slots:
};
#endif // UNZIP_H
#ifndef UNZIP_H
#define UNZIP_H
#include <QProcess>
#include <QObject>
#include <QString>
class UnZip: public QObject
{
Q_OBJECT
public:
QProcess unZipproc;
explicit UnZip(QObject *parent = 0);
public slots:
void unzipfile(QString filename);
};
#endif // UNZIP_H
To copy to clipboard, switch view to plain text mode
unzip.cpp
#include "unzip.h"
#include <QString>
#include <QStringList>
{}
void UnZip
::unzipfile(QString filename
) {
list << "e" << filename;
unZipproc.startDetached("7z", list);
}
#include "unzip.h"
#include <QString>
#include <QStringList>
UnZip::UnZip(QObject *parent) : QObject(parent)
{}
void UnZip::unzipfile(QString filename)
{
QStringList list;
list << "e" << filename;
unZipproc.startDetached("7z", list);
}
To copy to clipboard, switch view to plain text mode
and recieve error - ..\comicview\\unzip.h:8: error: undefined reference to `vtable for UnZip'
------------
ookk new qmake solve the problem
Added after 45 minutes:
rewrite unzip as
void UnZip
::unzipfile(QString filename
) {
list << "x" << filename << "-oc:\comictemp" << "-r";
unZipproc.startDetached(program, list);
}
void UnZip::unzipfile(QString filename)
{
QString program = "/7-Zip/7z.exe";
QStringList list;
list << "x" << filename << "-oc:\comictemp" << "-r";
unZipproc.startDetached(program, list);
}
To copy to clipboard, switch view to plain text mode
at open .cbz in program run windows console. show unzip process, but at finish folder comictemp on C: doesn`t exist.
When i write this comand at windows cmd, all work right and folder with files exist.
What is wrong?
-------------
okk need second \ before c:
list << "x" << filename << "-oc:\\comictemp" << "-r";
Bookmarks