Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. No matching function for call to 'QProcess::QProcess(Process* const)'

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

Scheduled Pinned Locked Moved General and Desktop
3 Posts 2 Posters 2.6k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • I Offline
    I Offline
    iacoposk8
    wrote on last edited by
    #1

    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]

    1 Reply Last reply
    0
    • T Offline
      T Offline
      t3685
      wrote on last edited by
      #2

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

      1 Reply Last reply
      0
      • I Offline
        I Offline
        iacoposk8
        wrote on last edited by
        #3

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

        1 Reply Last reply
        0

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved