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. QT no such slot with Q_Object

QT no such slot with Q_Object

Scheduled Pinned Locked Moved General and Desktop
slots
10 Posts 5 Posters 3.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.
  • H Offline
    H Offline
    Hystreal
    wrote on last edited by
    #1

    Hi everyone,

    I have some issue on Qt 5.5, when i want to add a slot to my class :

    QObject::connect: No such slot plugin_test::startCompteur()
    QObject::connect: (sender name: 'startButton')
    QObject::connect: (receiver name: 'plugin_test')


    #ifndef PLUGIN_TEST_H
    #define PLUGIN_TEST_H

    #include <QDialog>

    namespace Ui {
    class plugin_test;
    }

    class plugin_test : public QDialog
    {
    Q_OBJECT

    public:
    explicit plugin_test(QWidget *parent = 0);
    ~plugin_test();

    private:
    Ui::plugin_test *ui;

    private slots :

    void startCompteur();

    };
    #endif // PLUGIN_TEST_H

    #include "plugin_test.h"
    #include "ui_plugin_test.h"

    #include "capture_file.h"

    #include <config.h>

    #include "cfile.h"
    #include "file.h"
    #include "fileset.h"

    plugin_test::plugin_test(QWidget *parent) :
    QDialog(parent),
    ui(new Ui::plugin_test)
    {

    ui->setupUi(this);
    connect(ui->startButton, SIGNAL(clicked()), this, SLOT(startCompteur()));
    

    }

    plugin_test::~plugin_test()
    {
    delete ui;
    }

    void plugin_test::startCompteur()
    {
    //here my code
    }

    thanks for your help

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi and welcome to devnet,

      Pretty strange, did you do anything beside adding the slot to your class ?

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0
      • hskoglundH Online
        hskoglundH Online
        hskoglund
        wrote on last edited by
        #3

        Hmm just guessing, perhaps some name collision with the Wireshark include files?
        Try some other name than startCompteur()...

        1 Reply Last reply
        0
        • H Offline
          H Offline
          Hystreal
          wrote on last edited by
          #4

          SGaist :

          I'm working on wireshark source code and i've just add a new class with one slot.

          hskoglund :

          I already tried with another name like test_slot that i'm pretty sur there is no similar name but still doesn't work.

          mrjjM 1 Reply Last reply
          0
          • H Hystreal

            SGaist :

            I'm working on wireshark source code and i've just add a new class with one slot.

            hskoglund :

            I already tried with another name like test_slot that i'm pretty sur there is no similar name but still doesn't work.

            mrjjM Offline
            mrjjM Offline
            mrjj
            Lifetime Qt Champion
            wrote on last edited by mrjj
            #5

            @Hystreal said:

            And its not because its private and you hook it up in Dialog ?
            maybe try with new syntax ?
            connect(sender, &Sender::valueChanged, receiver, &Receiver::updateValue );

            since it gives better warnings/more type strict.

            1 Reply Last reply
            0
            • H Offline
              H Offline
              Hystreal
              wrote on last edited by
              #6

              Did you mean this synthax without SIGNAL and SLOT ?

              connect(ui->startButton, &sender::pressed(), this, &receivers::startCompteur());

              or

              connect(ui->startButton, SIGNAL(&sender::pressed()), this, SLOT(&receivers::startCompteur()));

              or maybe i've not totally understood...

              Anyways these synthaxes still doesn't work

              jsulmJ 1 Reply Last reply
              0
              • H Hystreal

                Did you mean this synthax without SIGNAL and SLOT ?

                connect(ui->startButton, &sender::pressed(), this, &receivers::startCompteur());

                or

                connect(ui->startButton, SIGNAL(&sender::pressed()), this, SLOT(&receivers::startCompteur()));

                or maybe i've not totally understood...

                Anyways these synthaxes still doesn't work

                jsulmJ Offline
                jsulmJ Offline
                jsulm
                Lifetime Qt Champion
                wrote on last edited by
                #7

                @Hystreal

                connect(ui->startButton, &sender::pressed(), this, &receivers::startCompteur()); is wrong, it should be:
                connect(ui->startButton, &sender::pressed, this, &receivers::startCompteur);
                

                https://forum.qt.io/topic/113070/qt-code-of-conduct

                1 Reply Last reply
                1
                • H Offline
                  H Offline
                  Hystreal
                  wrote on last edited by
                  #8

                  OK, i tried and now i have the followings errors :

                  erreur : C2653: 'sender' : is not a class or namespace name
                  erreur : C2065: 'pressed' : undeclared identifier
                  erreur : C2653: 'receivers' : is not a class or namespace name
                  erreur : C2276: '&' : illegal operation on bound member function expression

                  jsulmJ 1 Reply Last reply
                  0
                  • H Hystreal

                    OK, i tried and now i have the followings errors :

                    erreur : C2653: 'sender' : is not a class or namespace name
                    erreur : C2065: 'pressed' : undeclared identifier
                    erreur : C2653: 'receivers' : is not a class or namespace name
                    erreur : C2276: '&' : illegal operation on bound member function expression

                    jsulmJ Offline
                    jsulmJ Offline
                    jsulm
                    Lifetime Qt Champion
                    wrote on last edited by
                    #9

                    @Hystreal That's because you are doing it completely wrong, it should be (don't know what the class is where startCompteur is, change it accordingly):

                    connect(ui->startButton, &QPushButton::pressed, this, &Receiver::startCompteur);
                    

                    https://forum.qt.io/topic/113070/qt-code-of-conduct

                    1 Reply Last reply
                    0
                    • H Offline
                      H Offline
                      Hystreal
                      wrote on last edited by
                      #10

                      Ok sorry , it works now ! thanks you very much !

                      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