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. Object::connect: No such slot QApplication::foo
QtWS25 Last Chance

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

Scheduled Pinned Locked Moved General and Desktop
6 Posts 3 Posters 5.4k 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.
  • M Offline
    M Offline
    martonmiklos
    wrote on last edited by
    #1

    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
    0
    • F Offline
      F Offline
      francomartins
      wrote on last edited by
      #2

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

      1 Reply Last reply
      0
      • M Offline
        M Offline
        martonmiklos
        wrote on last edited by
        #3

        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
        0
        • K Offline
          K Offline
          KevinKnowles
          wrote on last edited by
          #4

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

          1 Reply Last reply
          0
          • M Offline
            M Offline
            martonmiklos
            wrote on last edited by
            #5

            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
            0
            • M Offline
              M Offline
              martonmiklos
              wrote on last edited by
              #6

              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
              0

              • Login

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