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. [Solved] No such signal - My own class

[Solved] No such signal - My own class

Scheduled Pinned Locked Moved General and Desktop
5 Posts 3 Posters 9.3k 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.
  • D Offline
    D Offline
    dpatrick
    wrote on last edited by
    #1

    Dear all,

    I created my own PushButton to receive a signal when my button get focus. Please see code below:

    @
    class MyPushButton : public QPushButton
    {
    Q_OBJECT

    public:
    MyPushButton(QWidget *parent = 0);

    signals:
    void getFocus();

    protected:
    void focusInEvent (QFocusEvent * event);

    };

    MyPushButton::MyPushButton(QWidget *parent) :
    QPushButton(parent)
    {
    }

    void MyPushButton::focusInEvent (QFocusEvent * event)
    {
    emit getFocus();
    QPushButton::focusInEvent(event);
    }

    @

    And in the main application I connect the signal to the slot.

    @
    connect(ui->btn1, SIGNAL(gotFocus()), this, SLOT(gotFocus1()));
    @

    When I start the application, I receive the following message:

    @
    Object::connect: No such signal MyPushButton::gotFocus() in ../page1.cpp:26
    Object::connect: (sender name: 'btn1')
    Object::connect: (receiver name 'Page1')
    @

    So, what is wrong in my code? Any ideas?

    I promoted my QPushButton to MyPushButton.

    Thanks a lot.

    1 Reply Last reply
    0
    • I Offline
      I Offline
      iunknwn
      wrote on last edited by
      #2

      Typo: Error is for gotFocus. Signal name is getFocus.

      Vista x64 with Qt 4.8.2 and VS2010

      1 Reply Last reply
      0
      • I Offline
        I Offline
        iunknwn
        wrote on last edited by
        #3

        Good Programming Practice: If you are using Visual Studio, let intellisense type the signal out as
        @connect(sender, SIGNAL(sender->signalName())....@
        Once you get it filled, delete "sender->". This way you can never get the signal name typed incorrectly.

        Vista x64 with Qt 4.8.2 and VS2010

        1 Reply Last reply
        0
        • A Offline
          A Offline
          alexander
          wrote on last edited by
          #4

          [quote author="iunknwn" date="1289581834"]Good Programming Practice: If you are using Visual Studio, let intellisense type the signal out as
          Once you get it filled, delete "sender->". This way you can never get the signal name typed incorrectly.
          [/quote]

          or use QtCreator, it shows available signals when you write code.

          1 Reply Last reply
          0
          • D Offline
            D Offline
            dpatrick
            wrote on last edited by
            #5

            Thanks a lot, I could not see my mistake.

            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