No matching function for call to 'QProcess::QProcess(Process* const)'



  • hello everyone! I managed to use QProcess in the main, but now I would like to organize it in a separate class, I wrote this

    process.h
    [code]
    #ifndef PROCESS_H
    #define PROCESS_H

    class Process
    {
    public:
    Process(QString cmd);
    public slots:
    void ReadOut();
    void ReadErr();
    };

    #endif // PROCESS_H
    [/code]

    process.cpp
    [code]
    #include "process.h"
    #include "qprocess.h"

    Process::Process(QString cmd)
    {
    QProcess *p = new QProcess( this );
    if (p)
    {
    p->setEnvironment( QProcess::systemEnvironment() );
    p->setProcessChannelMode( QProcess::MergedChannels );

        p->start( cmd );
        p->waitForStarted();
    
        QObject::connect( p, SIGNAL(readyReadStandardOutput()), this, SLOT(ReadOut()) );
        QObject::connect( p, SIGNAL(readyReadStandardError()), this, SLOT(ReadErr()) );
    }
    

    }

    void Process::ReadOut(){
    QProcess *p = dynamic_cast<QProcess *>( sender() );

    if (p)
      qWarning() << p->readAllStandardOutput(); 
    

    }

    void Process::ReadErr(){
    QProcess *p = dynamic_cast<QProcess *>( sender() );

    if (p)
      qWarning() << p->readAllStandardOutput(); 
    

    }
    [/code]

    and this is the error
    [code]
    /home/mezzo/Qt/Test/process.cpp:6: error: no matching function for call to 'QProcess::QProcess(Process* const)'
    QProcess *p = new QProcess( this );
    ^
    [/code]



  • QProcess takes a pointer to a QObject in its constructor. Your class does not derive from QObject.



  • so the problem is "this"? and as I modify it?


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.