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. QObject::Connect no such signal error but cannot see anything wrong :(
Forum Updated to NodeBB v4.3 + New Features

QObject::Connect no such signal error but cannot see anything wrong :(

Scheduled Pinned Locked Moved General and Desktop
5 Posts 3 Posters 10.9k Views 1 Watching
  • 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.
  • K Offline
    K Offline
    kpks
    wrote on last edited by
    #1

    Hi
    My mainwindow class has 2 main objects, a dataDisp and a data Plotter. As a first step all I am trying to do is connect the peak detection in the dataDisp to the mainwindow with signals and slots before I try to connect it to the data display class.
    I have attached the mainwindow and dataDisp classes. But I keep getting no such signal errors.
    @#ifndef MAINWINDOW_H
    #define MAINWINDOW_H

    #include <QMainWindow>
    #include <QtWidgets>
    #include "dynamicplots.h"
    #include "dispdata.h"
    #include "cprServer.h"

    namespace Ui {
    class MainWindow;
    }
    class dynamicPlots;
    class MainWindow : public QMainWindow
    {
    Q_OBJECT

    public:
    explicit MainWindow(QWidget parent = 0);
    ~MainWindow();
    void setPlotWindow(dynamicPlots
    dp);

    private slots:
    void updatePeak(int val, int index);
    void on_quitButton_clicked();

    void on_pbFiles_clicked();
    

    private:
    void setUpListener();
    dynamicPlots dPlot;
    Ui::MainWindow ui;
    dispData
    rawData;
    cprServer
    server;
    int newPeak;
    int newRecoil;
    int newRate;
    int newTime;
    };

    #endif // MAINWINDOW_H
    #ifndef DISPDATA_H
    #define DISPDATA_H
    #include <QObject>
    #include <vector>
    class dispData : public QObject
    {
    Q_OBJECT
    public:
    dispData(QObject* parent);
    void setStartIndex(int val){startIndex = val;}
    void addData(int val, int index);
    void updatePeakVals(int val, int index);
    int getPeakDepth(){return peakDepth;}
    int getTimeMark(){return markTime;}

    signals:
    void newPeakDepth(int peakDepth,int markTime);

    private:
    int startIndex;
    int value;
    int peakDepth;
    int markTime;
    int peakRecoil;
    int compressionCount;
    int compressionRate;
    std::vector<int> rawReads;
    std::vector<int> rawIndex;

    };

    #endif // DISPDATA_H
    #include "mainwindow.h"
    #include "ui_mainwindow.h"
    #include "cprserver.h"

    MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow)
    {
    const QString IP = "127.0.0.1";
    const ushort port = 8100;
    ui->setupUi(this);
    rawData = new dispData (this);
    server = new cprServer(this,rawData,port);
    connect(this->rawData,SIGNAL(rawData->newPeakDepth(int,int)),this,SLOT(updatePeak(int, int)));

    }

    MainWindow::~MainWindow()
    {
    delete ui;
    }
    void MainWindow::updatePeak(int val,int index)
    {
    newPeak=val;
    newTime=index;
    }

    void MainWindow::on_quitButton_clicked()
    {
    close();
    }

    void MainWindow::on_pbFiles_clicked()
    {
    setUpListener();
    this->hide();
    dPlot->show();

    }
    void MainWindow::setUpListener()
    {
    const QString IP = "127.0.0.1";
    const ushort port = 8100;
    QHostAddress host;

    host.setAddress(IP);
    //server->setRawData(rawData);
    if (!server->listen(host,port)) {
        QMessageBox::critical(this, tr("CPR Server"),
                              tr("Unable to start the server: %1.")
                              .arg(server->errorString()));
        close();
        //qDebug() <<  "Unable to start server" << server.errorString();
    
    }
    QString ipAddress=(server->serverAddress()).toString();
    qDebug () << "Server started at " << ipAddress ;//go to log
    

    }

    void MainWindow::setPlotWindow(dynamicPlots* dp)
    {
    dPlot = dp;
    }@

    Please somebody help!

    1 Reply Last reply
    0
    • sierdzioS Offline
      sierdzioS Offline
      sierdzio
      Moderators
      wrote on last edited by
      #2

      You have 2 errors:
      @
      connect(this->rawData,SIGNAL(rawData->newPeakDepth(int,int)), this, SLOT(updatePeak(int, int))); // WRONG!

      connect(rawData,SIGNAL(newPeakDepth(int,int)), this, SLOT(updatePeak(int, int))); // CORRECT
      @

      And another one is that you have declared "updatePeak" as private slot: I'm acutally not sure, but it might be considered invisible in this situation. If it does not work after you correct error 1, then declare that slot as public.

      (Z(:^

      1 Reply Last reply
      0
      • K Offline
        K Offline
        kpks
        wrote on last edited by
        #3

        Oh Thank you so much! The first fix did it! And I have literally spent 2.5 hours on this - it is 12.30 AM here in my time zone; My two poor boys have borne the brunt of my frustration on a usually fun friday evening

        1 Reply Last reply
        0
        • sierdzioS Offline
          sierdzioS Offline
          sierdzio
          Moderators
          wrote on last edited by
          #4

          Maybe you should have asked earlier :) Take it easy, Qt is great, but it will require some learning. Have fun and good night :D

          (Z(:^

          1 Reply Last reply
          0
          • JoeBermejalesJ Offline
            JoeBermejalesJ Offline
            JoeBermejales
            wrote on last edited by
            #5

            thanks, it solved my problem too! :)

            http://reparacionplotter.com

            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