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. No such slot
Qt 6.11 is out! See what's new in the release blog

No such slot

Scheduled Pinned Locked Moved General and Desktop
3 Posts 2 Posters 1.3k 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.
  • G Offline
    G Offline
    great88
    wrote on last edited by
    #1

    Something I don't understand about slots i guess . My slot function never gets called .
    I see a message that says :
    QObject::connect: No such slot Lobby::Lobby::onMyButtonClick() in lobby.cpp:13

    @#pragma once

    #include <QtWidgets/QWidget>

    class Lobby : public QWidget
    {

    Q_OBJECT

    public:
    Lobby(QWidget *parent = 0);

    protected:
    void keyPressEvent(QKeyEvent * e);
    void closeEvent(QCloseEvent * e);

    public slots:
    void onMyButtonClick();

    };

    #include <QPushButton>
    #include <QApplication>
    #include <QKeyEvent>
    #include "lobby.h"

    Lobby::Lobby(QWidget *parent)
    : QWidget(parent)
    {
    QPushButton *myButton = new QPushButton("button", this);
    myButton->setGeometry(50, 40, 75, 30);

    connect(myButton, SIGNAL(clicked()), this, SLOT(Lobby::onMyButtonClick()));
    }

    void Lobby::onMyButtonClick()
    {

    //

    }
    @

    1 Reply Last reply
    0
    • G Offline
      G Offline
      great88
      wrote on last edited by
      #2

      Never mind ... I changed Lobby::onMyButtonClick() to onMyButtonClick() and it works now . I originally had onMyButtonClick() and wasn't working either so I am not sure what was the fix though .

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

        Hi,

        The SLOT and SIGNAL function signatures must not contain the class name, only the function name and argument types.

        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

        • Login

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