Hello, i'm here again with another problem like last one, when the "error" signal is emitted into a slot called by a signal generated from QProcess i can't hook it. Down here the code.
Thanks
clientsocket.h
#include <QTcpSocket>
#include <QtGui>
#include "callApplication.h"
{
Q_OBJECT
private slots:
void error();
void readClient();
private:
CallApplication *callApplication;
};
#include <QTcpSocket>
#include <QtGui>
#include "callApplication.h"
class ClientSocket : public QTcpSocket
{
Q_OBJECT
private slots:
void error();
void readClient();
private:
CallApplication *callApplication;
};
To copy to clipboard, switch view to plain text mode
clientsocket.cpp
{
callApplication = new CallApplication(this->textBrowserPark);
connect(callApplication,
SIGNAL(error
(const QString)),
this,
SLOT(generateError
(const QString)));
connect(this, SIGNAL(readyRead()), this, SLOT(readClient()));
}
ClientSocket::readClient(){
//read something from client...
callApplication->performApplication();
}
void ClientSocket
::error(QString error
) {
//send a string to the client
}
ClientSocket::ClientSocket(QTextBrowser *textBrowser)
{
callApplication = new CallApplication(this->textBrowserPark);
connect(callApplication, SIGNAL(error(const QString)), this, SLOT(generateError(const QString)));
connect(this, SIGNAL(readyRead()), this, SLOT(readClient()));
}
ClientSocket::readClient(){
//read something from client...
callApplication->performApplication();
}
void ClientSocket::error(QString error)
{
//send a string to the client
}
To copy to clipboard, switch view to plain text mode
callApplication.h
#include <QProcess>
class CallApplication
: public QObject{
Q_OBJECT
public:
CallApplication();
signals:
void error();
private:
performApplication();
private slots:
void updateError();
void processFinished
(int exitCode,
QProcess::ExitStatus exitStatus
);
void processError
(QProcess::ProcessError error
);
public:
};
#include <QProcess>
class CallApplication : public QObject
{
Q_OBJECT
public:
CallApplication();
signals:
void error();
private:
performApplication();
private slots:
void updateError();
void processFinished(int exitCode, QProcess::ExitStatus exitStatus);
void processError(QProcess::ProcessError error);
public:
QProcess process;
};
To copy to clipboard, switch view to plain text mode
callApplication.cpp
CallApplication::CallApplication()
{
connect(&process, SIGNAL(readyReadStandardError()), this, SLOT(updateError()));
connect(&process,
SIGNAL(finished
(int,
QProcess::ExitStatus)),
this,
SLOT(processFinished
(int,
QProcess::ExitStatus)));
connect(&process,
SIGNAL(error
(QProcess::ProcessError)),
this,
SLOT(processError
(QProcess::ProcessError)));
}
void CallApplication::performApplication()
{
emit error(); //this is working correctly, signal connected into clientsocket.cpp
}
void CallApplication
::processFinished(int exitCode,
QProcess::ExitStatus exitStatus
) {
if (exitStatus
== QProcess::CrashExit) { } else if (exitCode != 0) {
emit error("Qprocess ended"); //it dosen't work, neither the signals emit into processError, signal connected into clientsocket.cpp
}
}
CallApplication::CallApplication()
{
connect(&process, SIGNAL(readyReadStandardError()), this, SLOT(updateError()));
connect(&process, SIGNAL(finished(int, QProcess::ExitStatus)), this, SLOT(processFinished(int, QProcess::ExitStatus)));
connect(&process, SIGNAL(error(QProcess::ProcessError)), this, SLOT(processError(QProcess::ProcessError)));
}
void CallApplication::performApplication()
{
emit error(); //this is working correctly, signal connected into clientsocket.cpp
}
void CallApplication::processFinished(int exitCode, QProcess::ExitStatus exitStatus)
{
if (exitStatus == QProcess::CrashExit) {
} else if (exitCode != 0) {
emit error("Qprocess ended"); //it dosen't work, neither the signals emit into processError, signal connected into clientsocket.cpp
}
}
To copy to clipboard, switch view to plain text mode
Bookmarks