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. Signals&Slots Error: No matching function for call to 'connect' (requires 3 arguments, but 4 were provided)

Signals&Slots Error: No matching function for call to 'connect' (requires 3 arguments, but 4 were provided)

Scheduled Pinned Locked Moved Solved General and Desktop
signal & slotqcustomplot
4 Posts 3 Posters 2.1k 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.
  • T Offline
    T Offline
    TUStudi
    wrote on 4 Mar 2020, 17:34 last edited by
    #1

    Hello,

    I am trying the following:

    I have a .ui form and I want to make a Plot with QCustomPlot in one widget on this form. But I do not want to write the code that is necassary in the mainwindow.cpp but creating a new class, setting up the diagramm there and call this method from my mainwindow.cpp file, like this:

    /*PlotterModel.cpp*/
    
    
    #include "PlotterModel.h"
    #include "ui_PlotterView.h"
    
    PlotterModel::PlotterModel()
    { 
    }
    
    
    void PlotterModel::setUpPlot(QCustomPlot *customPlotWidget)
    {
        customPlotWidget->addGraph(); // blue line
        customPlotWidget->graph(0)->setPen(QPen(QColor(40, 110, 255)));
        customPlotWidget->addGraph(); // red line
        customPlotWidget->graph(1)->setPen(QPen(QColor(255, 110, 40)));
    
        QSharedPointer<QCPAxisTickerTime> timeTicker(new QCPAxisTickerTime);
        timeTicker->setTimeFormat("%h:%m:%s");
        customPlot->xAxis->setTicker(timeTicker);
        customPlot->axisRect()->setupFullAxesBox();
        customPlot->yAxis->setRange(-1.2, 1.2);
    
        // make left and bottom axes transfer their ranges to right and top axes:
        connect(customPlotWidget->xAxis, SIGNAL(rangeChanged(QCPRange)), customPlotWidget->xAxis2, SLOT(setRange(QCPRange)));
        connect(customPlotWidget->yAxis, SIGNAL(rangeChanged(QCPRange)), customPlotWidget->yAxis2, SLOT(setRange(QCPRange)));
    
        // setup a timer that repeatedly calls MainWindow::realtimeDataSlot:
        connect(dataTimer, SIGNAL(timeout()), this, SLOT(realtimeDataSlot()));
        dataTimer->start(0); // Interval 0 means to refresh as fast as possible
    }
    
    

    here is my header file for this class

    /*PlotterModel.h*/
    
    #ifndef PLOTTERMODEL_H
    #define PLOTTERMODEL_H
    #include <qcustomplot.h>
    #include <QTimer>
    
    class PlotterModel
    {
        Q_OBJECT
    
    public:
        PlotterModel();
        void setUpAccelerationDiagram(QCustomPlot *customPlotWidget);
    
          QTimer *dataTimer = new QTimer();
    };
    
    #endif // PLOTTERMODEL_H
    
    

    So, now I want to call the above defined method setupPlot() and the parameter is my widget in my .ui file which I promotet to QCustomPlot as in the basic tutorial. So how can I call this method from my mainwindow.cpp file, can I call ui->customPlotWidget->replot() from my mainwindow.cpp? Because all my connect statements from my method setupPlot() give me the error:

    PlotterModel.cpp:29:5: error: no matching function for call to 'connect'
    winsock.h:751:16: note: candidate function not viable: requires 3 arguments, but 4 were provided
    
    P 1 Reply Last reply 4 Mar 2020, 18:43
    0
    • C Online
      C Online
      Christian Ehrlicher
      Lifetime Qt Champion
      wrote on 4 Mar 2020, 18:36 last edited by
      #2

      Since PlotterModel is not derived from QObject there is also no function QObject::connect() which could be called. So it's using another connect function from winsock.h which does not match.
      --> you forgot to derive from QObject (although you already added Q_OBJECT which should trigger a warning).

      Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
      Visit the Qt Academy at https://academy.qt.io/catalog

      1 Reply Last reply
      5
      • T TUStudi
        4 Mar 2020, 17:34

        Hello,

        I am trying the following:

        I have a .ui form and I want to make a Plot with QCustomPlot in one widget on this form. But I do not want to write the code that is necassary in the mainwindow.cpp but creating a new class, setting up the diagramm there and call this method from my mainwindow.cpp file, like this:

        /*PlotterModel.cpp*/
        
        
        #include "PlotterModel.h"
        #include "ui_PlotterView.h"
        
        PlotterModel::PlotterModel()
        { 
        }
        
        
        void PlotterModel::setUpPlot(QCustomPlot *customPlotWidget)
        {
            customPlotWidget->addGraph(); // blue line
            customPlotWidget->graph(0)->setPen(QPen(QColor(40, 110, 255)));
            customPlotWidget->addGraph(); // red line
            customPlotWidget->graph(1)->setPen(QPen(QColor(255, 110, 40)));
        
            QSharedPointer<QCPAxisTickerTime> timeTicker(new QCPAxisTickerTime);
            timeTicker->setTimeFormat("%h:%m:%s");
            customPlot->xAxis->setTicker(timeTicker);
            customPlot->axisRect()->setupFullAxesBox();
            customPlot->yAxis->setRange(-1.2, 1.2);
        
            // make left and bottom axes transfer their ranges to right and top axes:
            connect(customPlotWidget->xAxis, SIGNAL(rangeChanged(QCPRange)), customPlotWidget->xAxis2, SLOT(setRange(QCPRange)));
            connect(customPlotWidget->yAxis, SIGNAL(rangeChanged(QCPRange)), customPlotWidget->yAxis2, SLOT(setRange(QCPRange)));
        
            // setup a timer that repeatedly calls MainWindow::realtimeDataSlot:
            connect(dataTimer, SIGNAL(timeout()), this, SLOT(realtimeDataSlot()));
            dataTimer->start(0); // Interval 0 means to refresh as fast as possible
        }
        
        

        here is my header file for this class

        /*PlotterModel.h*/
        
        #ifndef PLOTTERMODEL_H
        #define PLOTTERMODEL_H
        #include <qcustomplot.h>
        #include <QTimer>
        
        class PlotterModel
        {
            Q_OBJECT
        
        public:
            PlotterModel();
            void setUpAccelerationDiagram(QCustomPlot *customPlotWidget);
        
              QTimer *dataTimer = new QTimer();
        };
        
        #endif // PLOTTERMODEL_H
        
        

        So, now I want to call the above defined method setupPlot() and the parameter is my widget in my .ui file which I promotet to QCustomPlot as in the basic tutorial. So how can I call this method from my mainwindow.cpp file, can I call ui->customPlotWidget->replot() from my mainwindow.cpp? Because all my connect statements from my method setupPlot() give me the error:

        PlotterModel.cpp:29:5: error: no matching function for call to 'connect'
        winsock.h:751:16: note: candidate function not viable: requires 3 arguments, but 4 were provided
        
        P Offline
        P Offline
        Pl45m4
        wrote on 4 Mar 2020, 18:43 last edited by
        #3

        @TUStudi said in Signals&Slots Error: No matching function for call to 'connect' (requires 3 arguments, but 4 were provided):

        So how can I call this method from my mainwindow.cpp file

        In MainWindow.cpp

        PlotterModel *pM = new PlotterModel();
        
        pM->setupPlot( ui->yourCustomPlotWidget );
        

        or use a connection to setup your PlotterModel on mainWindow initialization.


        If debugging is the process of removing software bugs, then programming must be the process of putting them in.

        ~E. W. Dijkstra

        1 Reply Last reply
        1
        • T Offline
          T Offline
          TUStudi
          wrote on 4 Mar 2020, 20:42 last edited by
          #4

          Thank you both, it works now.

          1 Reply Last reply
          0

          4/4

          4 Mar 2020, 20:42

          • Login

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