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 Solved General and Desktop
13 Posts 5 Posters 3.4k Views 2 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.
  • P Offline
    P Offline
    ProgrammerAtHeart3344
    wrote on last edited by
    #1
    QObject::connect: No such slot <class name>::this->ResponseOneClicked() in <class name>.cpp:8
    QObject::connect:  (sender name:   'ResponseOneBtn')_
    QObject::connect:  (receiver name: '<classname>Class')
    

    As you can see, I get this error when I try to use the slot. Here is the header file. Class name removed as it is kind of inappropriate.

    class <class name> : public QMainWindow
    {
    	Q_OBJECT
    
    public:
    	<class name>(QWidget *parent = 0);
    	~<class name>;
    
    	QPushButton* getResponseOne();
    	QPushButton* getResponseTwo();
    	QPushButton* getResponseThree();
    	QPushButton* getResponseFour();
    	QPushButton* getShowTweet();
    	QFrame* getTweetFrame();
    
    	public slots:
    	void ResponseOneClicked();
    	void ResponseTwlClicked();
    	void ResponseThreeClicked();
    	void ResponseFourClicked();
    	void ShowTweet();
    	void ShowFrame();
    

    what can I do to fix this? Am I doing it right?

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

      Can you show how you connect the signal to that slot?

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

      P 1 Reply Last reply
      0
      • jsulmJ jsulm

        Can you show how you connect the signal to that slot?

        P Offline
        P Offline
        ProgrammerAtHeart3344
        wrote on last edited by
        #3

        @jsulm

        <class name>::<class name>(QWidget *parent)
        	: QMainWindow(parent)
        {
        	ui.setupUi(this);
        	this->disableAndHide();
        	QObject::connect(this->getResponseOne(), SIGNAL(clicked()), this, SLOT(this->ResponseOneClicked()));
        
        }
        
        W 1 Reply Last reply
        0
        • jsulmJ Offline
          jsulmJ Offline
          jsulm
          Lifetime Qt Champion
          wrote on last edited by
          #4

          The problem is most probably this: SLOT(this->ResponseOneClicked()) - remove this->.
          No need to use QObject:: in front of connect.
          No need to use this-> in this->disableAndHide();
          No need to use this-> in this->getResponseOne()
          Why do you call this->getResponseOne() to get the pointer to the button? Don't you have the pointer in the same class already?

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

          kshegunovK 1 Reply Last reply
          0
          • jsulmJ Offline
            jsulmJ Offline
            jsulm
            Lifetime Qt Champion
            wrote on last edited by
            #5
            connect(getResponseOne(), SIGNAL(clicked()), this, SLOT(ResponseOneClicked()));
            

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

            P 1 Reply Last reply
            1
            • jsulmJ jsulm
              connect(getResponseOne(), SIGNAL(clicked()), this, SLOT(ResponseOneClicked()));
              
              P Offline
              P Offline
              ProgrammerAtHeart3344
              wrote on last edited by
              #6

              @jsulm Thanks, I appreciate it.

              1 Reply Last reply
              0
              • jsulmJ jsulm

                The problem is most probably this: SLOT(this->ResponseOneClicked()) - remove this->.
                No need to use QObject:: in front of connect.
                No need to use this-> in this->disableAndHide();
                No need to use this-> in this->getResponseOne()
                Why do you call this->getResponseOne() to get the pointer to the button? Don't you have the pointer in the same class already?

                kshegunovK Offline
                kshegunovK Offline
                kshegunov
                Moderators
                wrote on last edited by
                #7

                @jsulm

                No need to use QObject:: in front of connect.

                True in principle. There are a few non-static overloads, however, and it's not a bad style to explicitly show the static function is used in this case. Overloading may get confusing if one of the other methods is used, e.g.:

                connect(getResponseOne(), SIGNAL(clicked()), SLOT(ResponseOneClicked()));
                

                Read and abide by the Qt Code of Conduct

                1 Reply Last reply
                1
                • P ProgrammerAtHeart3344

                  @jsulm

                  <class name>::<class name>(QWidget *parent)
                  	: QMainWindow(parent)
                  {
                  	ui.setupUi(this);
                  	this->disableAndHide();
                  	QObject::connect(this->getResponseOne(), SIGNAL(clicked()), this, SLOT(this->ResponseOneClicked()));
                  
                  }
                  
                  W Offline
                  W Offline
                  Walux
                  wrote on last edited by
                  #8

                  @ProgrammerAtHeart3344 said:

                  this->disableAndHide();
                  

                  Maybe by disabling your class , your slots are "disabled" too.

                  Taking things from beginning to end : That's my entertainment !

                  P 1 Reply Last reply
                  0
                  • W Walux

                    @ProgrammerAtHeart3344 said:

                    this->disableAndHide();
                    

                    Maybe by disabling your class , your slots are "disabled" too.

                    P Offline
                    P Offline
                    ProgrammerAtHeart3344
                    wrote on last edited by
                    #9

                    @Walux I managed to fix it, thank you. Having another problem now.

                    W 1 Reply Last reply
                    0
                    • P ProgrammerAtHeart3344

                      @Walux I managed to fix it, thank you. Having another problem now.

                      W Offline
                      W Offline
                      Walux
                      wrote on last edited by Walux
                      #10

                      @ProgrammerAtHeart3344

                      You're welcome , and you're free to post your new problem but in an another thread , to maintain information order in the forum :)

                      And please mark the topic as solved if it's the case :)

                      Taking things from beginning to end : That's my entertainment !

                      P 1 Reply Last reply
                      1
                      • W Walux

                        @ProgrammerAtHeart3344

                        You're welcome , and you're free to post your new problem but in an another thread , to maintain information order in the forum :)

                        And please mark the topic as solved if it's the case :)

                        P Offline
                        P Offline
                        ProgrammerAtHeart3344
                        wrote on last edited by
                        #11

                        @Walux How do I mark the topic as solved? Also, I did post my problem as a new thread. I just forget the name right now.

                        RatzzR 1 Reply Last reply
                        0
                        • P ProgrammerAtHeart3344

                          @Walux How do I mark the topic as solved? Also, I did post my problem as a new thread. I just forget the name right now.

                          RatzzR Offline
                          RatzzR Offline
                          Ratzz
                          wrote on last edited by
                          #12

                          @ProgrammerAtHeart3344 said:

                          How do I mark the topic as solved?

                          Refer this
                          http://forum.qt.io/topic/62700/hitchhiker-s-visual-guide-to-the-qt-forum

                          --Alles ist gut.

                          P 1 Reply Last reply
                          0
                          • RatzzR Ratzz

                            @ProgrammerAtHeart3344 said:

                            How do I mark the topic as solved?

                            Refer this
                            http://forum.qt.io/topic/62700/hitchhiker-s-visual-guide-to-the-qt-forum

                            P Offline
                            P Offline
                            ProgrammerAtHeart3344
                            wrote on last edited by
                            #13

                            @Ratzz Thank you.

                            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