Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Update: Forum Guidelines & Code of Conduct


    Qt World Summit: Early-Bird Tickets

    Object::connect: No such slot QApplication::foo

    General and Desktop
    3
    6
    5027
    Loading More Posts
    • 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.
    • M
      martonmiklos last edited by

      Hello all,

      I am writing an application, and I have ran into a strange problem. (At least it is trange for me.) I have done the similar trick in many times in this application and always went fine. The problem is possibly with me, but I could not solved it for a while, so I would like to ask you to review it. Rebuilding was also tried out.

      So I have a class:
      @#ifndef EGGFINDER_H
      #define EGGFINDER_H

      #include <QObject>
      #include "mapitems.h"
      #include "settings.h"

      class EggFinder : public QObject
      {
      Q_OBJECT
      public:
      EggFinder(QObject *parent = 0);

      private:
      QList<PyramidItem*> m_pyramids;
      void addPyramid(PyramidItem p) {m_pyramids.append(p);}
      void checkPyramid(PyramidItem
      );
      QImage *m_currentImage;

      signals:

      public slots:
      void foo(double a, double b);
      void newImageReceieved(QImage*);
      };

      #endif // EGGFINDER_H
      @

      An the implementation:
      @#include "eggfinder.h"
      #include <QImage>
      #include <QPainter>
      #include <QDebug>

      EggFinder::EggFinder(QObject *parent) :
      QObject(parent)
      {
      }

      void EggFinder::checkPyramid(PyramidItem *pyramid)
      {
      QImage pyramidImage(pyramid->boundingRect().size().toSize(), QImage::Format_ARGB32);
      pyramidImage = m_currentImage->copy(pyramid->boundingRect().toRect());
      pyramidImage.save("out.png");
      }

      void EggFinder::foo(double a, double b)
      {
      qWarning() << a << b;
      }

      void EggFinder::newImageReceieved(QImage* img)
      {
      m_currentImage = img;
      foreach (PyramidItem *pyramid, m_pyramids) {
      checkPyramid(pyramid);
      break;
      }
      }@

      I creating an instance in my MainWindow from it:

      @m_eggFinder = new EggFinder(this);@

      And here is where I am trying to connect to the object's slots:

      @
      void MainWindow::imageGrabberChanged(QImageGrabber ng)
      {
      currentGrabber = ng;
      disconnect(ui->graphicsViewMap, SLOT(newImageReceieved(QImage
      )));
      disconnect(m_imgProc, SLOT(newImageReceieved(QImage*)));
      disconnect(m_eggFinder, SLOT(newImageReceieved(QImage*))); // this is row 356
      connect(ng, SIGNAL(newImageGrabbed(QImage*)), ui->graphicsViewMap, SLOT(newImageReceieved(QImage*)));
      connect(ng, SIGNAL(newImageGrabbed(QImage*)), m_imgProc, SLOT(newImageReceieved(QImage*)));
      connect(ng, SIGNAL(newFPSCalculated(double,double)), this, SLOT(newFPSCalculated(double, double)));
      connect(ng, SIGNAL(newImageGrabbed(QImage*)), m_eggFinder, SLOT(newImageReceieved(QImage*))); // this is line 360
      connect(ng, SIGNAL(newFPSCalculated(double,double)), m_eggFinder, SLOT(foo(double,double))); // and this is 361
      }@

      An in the command line output it says the following, and of course he connections did not made:
      @Object::disconnect: No such slot QApplication::newImageReceieved(QImage*) in src/mainwindow.cpp:356
      Object::disconnect: (sender name: 'MainWindow')
      Object::disconnect: (receiver name: 'egger_controller')
      Object::connect: No such slot QApplication::newImageReceieved(QImage*) in src/mainwindow.cpp:360
      Object::connect: (receiver name: 'egger_controller')
      Object::connect: No such slot QApplication::foo(double, double) in src/mainwindow.cpp:361
      Object::connect: (receiver name: 'egger_controller')@

      The m_imgProc is similarly declared, implemented as my EggFinder class, and it is working.

      1 Reply Last reply Reply Quote 0
      • F
        francomartins last edited by

        show me the line 356,360 and 361 of code .

        1 Reply Last reply Reply Quote 0
        • M
          martonmiklos last edited by

          Check the code snipplet below the line:

          bq. And here is where I am trying to connect to the object’s slots:

          I have marked the problematic lines.

          1 Reply Last reply Reply Quote 0
          • K
            KevinKnowles last edited by

            What is egger_controller? Are you sure m_eggFinder is the type you think it is?

            1 Reply Last reply Reply Quote 0
            • M
              martonmiklos last edited by

              The egger_controller is the name of my application.
              Yes the m_eggfinder is declared in this way:

              @ EggFinder *m_eggFinder;@

              1 Reply Last reply Reply Quote 0
              • M
                martonmiklos last edited by

                Wahhh. Finally I have figured out what caused the problem.
                The imageGrabberChanged method gets called before the m_eggFinder instance created.
                I have no idea why did not caused SIGSEV ever.

                Thank you very much for your help!

                1 Reply Last reply Reply Quote 0
                • First post
                  Last post