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. QMetaObject::connectSlotsByName: No matching signal for on_{Object_Name}_valueChanged(int)
Forum Updated to NodeBB v4.3 + New Features

QMetaObject::connectSlotsByName: No matching signal for on_{Object_Name}_valueChanged(int)

Scheduled Pinned Locked Moved Unsolved General and Desktop
4 Posts 3 Posters 654 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.
  • A Offline
    A Offline
    AbhimanyuD
    wrote on last edited by
    #1

    Re: No matching signal for ...[SOLVED]

    I created a spinBox widget and tried connecting it to the valueChanged (int arg1) signal. The slot body is auto-generated. However, the slot is not triggered, and the application window complains - "QMetaObject::connectSlotsByName: No matching signal for on_{Object_Name}_valueChanged(int)."

    I have other spinBoxes connected to the same signal, i.e., valueChanged9int arg1), and they work fine. I would appreciate help on this topic. This is what has been tried so far after going through various forums. None worked.

    1. Cleaned the project and re-built and no luck.
    2. Removed the "on_" from the slot name and no luck.

    I am using MSVC2017 to build the software.

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

      Hi and welcome to devnet,

      While the feature is relatively nice, it's rather easy to trip it. The usual recommendation is to only use explicit connections. That way you ensure that everything you want is properly connected and if you change your widget name, you only have one place to change to keep it working.

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

      A 1 Reply Last reply
      1
      • SGaistS SGaist

        Hi and welcome to devnet,

        While the feature is relatively nice, it's rather easy to trip it. The usual recommendation is to only use explicit connections. That way you ensure that everything you want is properly connected and if you change your widget name, you only have one place to change to keep it working.

        A Offline
        A Offline
        AbhimanyuD
        wrote on last edited by AbhimanyuD
        #3

        @SGaist Thanks for your quick response.

        I agree with your suggestion. I tried the same, and it pointed to the root of the actual issue. So, my GUI form name is "gui_input.ui," and the auto-generated header is "ui_gui_inputif.h". I observed that when I make changes to the form (E.g., adding a new SpinBox or Button object) and save -> clean -> run q make -> Build & Run, the "ui_gui_inputif.h" is not reflecting my changes.

        So, as a next step, I modified the file manually and added the object (replicated the code for another object that seems to work fine).

        After that, I tried connecting the signal and slot with the below syntax.

        GUI_InputIf::GUI_InputIf(QWidget *parent) :
        QDialog(parent),
        ui(new Ui::GUI_InputIf)
        {
        ui->setupUi(this);

        connect(ui->LKA_L_STS, SIGNAL(valueChanged(int)), this, SLOT(LKA_L_STS_valueChanged(int)));

        }

        This is how my class declaration looks like:-

        class GUI_InputIf : public QDialog
        {
        Q_OBJECT

        public:
        GUI_InputIf(QWidget *parent);

        ~GUI_InputIf();
        

        private slots:
        void LKA_L_STS_valueChanged(int arg1);

        private:
        Ui::GUI_InputIf *ui;
        }

        This did NOT work. It did not see the slot called on changing the spinBox value.

        As a next step, I created my own signal and added it to the class. (See code below).

        class GUI_InputIf : public QDialog
        {
        Q_OBJECT

        public:
        GUI_InputIf(QWidget *parent);

        ~GUI_InputIf();
        

        private slots:
        void LKA_L_STS_valueChanged(int arg1);

        signals:
        void lkaValChanged(int arg1);

        private:
        Ui::GUI_InputIf *ui;
        }

        No luck with this as well. I am unsure how to make the spinBox trigger this signal on value change such that the slot is triggered. From where should I emit this signal?

        Axel SpoerlA 1 Reply Last reply
        0
        • A AbhimanyuD

          @SGaist Thanks for your quick response.

          I agree with your suggestion. I tried the same, and it pointed to the root of the actual issue. So, my GUI form name is "gui_input.ui," and the auto-generated header is "ui_gui_inputif.h". I observed that when I make changes to the form (E.g., adding a new SpinBox or Button object) and save -> clean -> run q make -> Build & Run, the "ui_gui_inputif.h" is not reflecting my changes.

          So, as a next step, I modified the file manually and added the object (replicated the code for another object that seems to work fine).

          After that, I tried connecting the signal and slot with the below syntax.

          GUI_InputIf::GUI_InputIf(QWidget *parent) :
          QDialog(parent),
          ui(new Ui::GUI_InputIf)
          {
          ui->setupUi(this);

          connect(ui->LKA_L_STS, SIGNAL(valueChanged(int)), this, SLOT(LKA_L_STS_valueChanged(int)));

          }

          This is how my class declaration looks like:-

          class GUI_InputIf : public QDialog
          {
          Q_OBJECT

          public:
          GUI_InputIf(QWidget *parent);

          ~GUI_InputIf();
          

          private slots:
          void LKA_L_STS_valueChanged(int arg1);

          private:
          Ui::GUI_InputIf *ui;
          }

          This did NOT work. It did not see the slot called on changing the spinBox value.

          As a next step, I created my own signal and added it to the class. (See code below).

          class GUI_InputIf : public QDialog
          {
          Q_OBJECT

          public:
          GUI_InputIf(QWidget *parent);

          ~GUI_InputIf();
          

          private slots:
          void LKA_L_STS_valueChanged(int arg1);

          signals:
          void lkaValChanged(int arg1);

          private:
          Ui::GUI_InputIf *ui;
          }

          No luck with this as well. I am unsure how to make the spinBox trigger this signal on value change such that the slot is triggered. From where should I emit this signal?

          Axel SpoerlA Online
          Axel SpoerlA Online
          Axel Spoerl
          Moderators
          wrote on last edited by
          #4

          @AbhimanyuD
          Generally, please format posted code. It’s just so much easier to read for everybody.
          What exactly happens in the modified example?
          Autoconnect by name will not work without the on_
          Have you tried connecting the PMF way?

          Software Engineer
          The Qt Company, Oslo

          1 Reply Last reply
          2

          • Login

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