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. QObject::connect: No such signal QTableWidget::itemChanged(QTableWidgetItem *item)
Forum Updated to NodeBB v4.3 + New Features

QObject::connect: No such signal QTableWidget::itemChanged(QTableWidgetItem *item)

Scheduled Pinned Locked Moved Solved General and Desktop
7 Posts 4 Posters 2.2k 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.
  • M Offline
    M Offline
    masayoshi
    wrote on last edited by masayoshi
    #1

    Could you edit my code ?
    I would like to use QTableWidget::itemChanged .

    QMetaObject::connectSlotsByName: No matching signal for on_table_itemChanged(QTableWidgetItem*)
    QObject::connect: No such signal QTableWidget::itemChanged(QTableWidgetItem *item) in ../test/mainwindow.cpp:29
    QObject::connect:  (receiver name: 'MainWindow')
    
    // mainewindow.cpp
    
    #include "mainwindow.h"
    #include "ui_mainwindow.h"
    #include <QtDebug>
    #include <QTableWidget>
    #include <QVBoxLayout>
    
    MainWindow::MainWindow(QWidget *parent) :
        QMainWindow(parent),
        ui(new Ui::MainWindow)
    {
        ui->setupUi(this);
    
    QVBoxLayout *layout = new QVBoxLayout;
     QTableWidget* table = new QTableWidget(this);
     table->setRowCount(10);
     table->setColumnCount(5);
    
     for(int row = 0; row < 10; row++)
      {
          QTableWidgetItem *Item = new QTableWidgetItem(tr("%1").arg(row*2));
          table->setItem(row, 0, Item);
    }
    
    layout->addWidget(table);
    
    MainWindow::centralWidget()->setLayout(layout);
    
    connect(table, SIGNAL(itemChanged(QTableWidgetItem *item)), SLOT(on_table_itemChanged(QTableWidgetItem *item)));
    
    
    }
    
    MainWindow::~MainWindow()
    {
        delete ui;
    }
    
    void MainWindow::on_table_itemChanged(QTableWidgetItem *item)
    {
        qDebug() << item->text() << endl ;
    }
    
    
    // mainwindow.h
    
    #ifndef MAINWINDOW_H
    #define MAINWINDOW_H
    #include <QTableWidget>
    #include <QMainWindow>
    
    namespace Ui {
    class MainWindow;
    }
    
    class MainWindow : public QMainWindow
    {
        Q_OBJECT
    
    public:
        explicit MainWindow(QWidget *parent = nullptr);
        ~MainWindow();
    
    private slots:
    
    
        void on_table_itemChanged(QTableWidgetItem *item);
    
    
    
    private:
        Ui::MainWindow *ui;
    };
    
    #endif // MAINWINDOW_H
    
    
    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

      Change the name of your slot to something like onTableItemChanged. The on_widget_signalName notation is used for the connectsSlotsByName feature. Since you create the widget in the constructor, it's not yet available when connectsSlotsByName is called through ui->setupUi(this).

      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
      • J.HilkJ Offline
        J.HilkJ Offline
        J.Hilk
        Moderators
        wrote on last edited by
        #3

        hi @masayoshi

        first, you should change the name of your slot. with a name like on_table_itemChanged

        you'll run into issues with the automatic connect by name functionality of Qt.

        I'll also suggest using the new Qt5 Syntax, it will report back compile time errors that are usually more useful.

        //void on_table_itemChanged(QTableWidgetItem *item);
        void onTableItemChanged(QTableWidgetItem *item);
        
        ...
        
        connect(table, &QTableWidget::itemChanged, this, &MainWindow::onTableItemChanged);
        

        Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct


        Q: What's that?
        A: It's blue light.
        Q: What does it do?
        A: It turns blue.

        M 1 Reply Last reply
        2
        • J.HilkJ J.Hilk

          hi @masayoshi

          first, you should change the name of your slot. with a name like on_table_itemChanged

          you'll run into issues with the automatic connect by name functionality of Qt.

          I'll also suggest using the new Qt5 Syntax, it will report back compile time errors that are usually more useful.

          //void on_table_itemChanged(QTableWidgetItem *item);
          void onTableItemChanged(QTableWidgetItem *item);
          
          ...
          
          connect(table, &QTableWidget::itemChanged, this, &MainWindow::onTableItemChanged);
          
          M Offline
          M Offline
          masayoshi
          wrote on last edited by masayoshi
          #4

          @J.Hilk said in QObject::connect: No such signal QTableWidget::itemChanged(QTableWidgetItem *item):

          hi @masayoshi

          first, you should change the name of your slot. with a name like on_table_itemChanged

          you'll run into issues with the automatic connect by name functionality of Qt.

          I'll also suggest using the new Qt5 Syntax, it will report back compile time errors that are usually more useful.

          //void on_table_itemChanged(QTableWidgetItem *item);
          void onTableItemChanged(QTableWidgetItem *item);
          
          ...
          
          connect(table, &QTableWidget::itemChanged, this, &MainWindow::onTableItemChanged);
          

          Thank you for reply. I got the following error.

          // 
          
          /usr/bin/ld: error: undefined symbol: MainWindow::onTableItemChanged(QTableWidgetItem*)
          >>> referenced by moc_mainwindow.cpp:74
          >>>               moc_mainwindow.o:(MainWindow::qt_static_metacall(QObject*, QMetaObject::Call, int, void**))
          clang++: error: linker command failed with exit code 1 (use -v to see invocation)
          *** [test] Error code 1
          
          // mainwindow.cpp
          

          connect(table, &QTableWidget::itemChanged, this, &MainWindow::onTableItemChanged);

          void MainWindow::onTableitemChanged(QTableWidgetItem *item)
          {
          qDebug() << item->text() << endl ;
          }

          // mainwindow.h
          
          
          void onTableItemChanged(QTableWidgetItem *item);
          
          J.HilkJ jsulmJ 2 Replies Last reply
          0
          • M masayoshi

            @J.Hilk said in QObject::connect: No such signal QTableWidget::itemChanged(QTableWidgetItem *item):

            hi @masayoshi

            first, you should change the name of your slot. with a name like on_table_itemChanged

            you'll run into issues with the automatic connect by name functionality of Qt.

            I'll also suggest using the new Qt5 Syntax, it will report back compile time errors that are usually more useful.

            //void on_table_itemChanged(QTableWidgetItem *item);
            void onTableItemChanged(QTableWidgetItem *item);
            
            ...
            
            connect(table, &QTableWidget::itemChanged, this, &MainWindow::onTableItemChanged);
            

            Thank you for reply. I got the following error.

            // 
            
            /usr/bin/ld: error: undefined symbol: MainWindow::onTableItemChanged(QTableWidgetItem*)
            >>> referenced by moc_mainwindow.cpp:74
            >>>               moc_mainwindow.o:(MainWindow::qt_static_metacall(QObject*, QMetaObject::Call, int, void**))
            clang++: error: linker command failed with exit code 1 (use -v to see invocation)
            *** [test] Error code 1
            
            // mainwindow.cpp
            

            connect(table, &QTableWidget::itemChanged, this, &MainWindow::onTableItemChanged);

            void MainWindow::onTableitemChanged(QTableWidgetItem *item)
            {
            qDebug() << item->text() << endl ;
            }

            // mainwindow.h
            
            
            void onTableItemChanged(QTableWidgetItem *item);
            
            J.HilkJ Offline
            J.HilkJ Offline
            J.Hilk
            Moderators
            wrote on last edited by J.Hilk
            #5

            @masayoshi
            you should clean your build folder and rerun qmake.


            Also did you by any chance forget to #include <QTableWidgetItem> ?


            Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct


            Q: What's that?
            A: It's blue light.
            Q: What does it do?
            A: It turns blue.

            1 Reply Last reply
            0
            • M masayoshi

              @J.Hilk said in QObject::connect: No such signal QTableWidget::itemChanged(QTableWidgetItem *item):

              hi @masayoshi

              first, you should change the name of your slot. with a name like on_table_itemChanged

              you'll run into issues with the automatic connect by name functionality of Qt.

              I'll also suggest using the new Qt5 Syntax, it will report back compile time errors that are usually more useful.

              //void on_table_itemChanged(QTableWidgetItem *item);
              void onTableItemChanged(QTableWidgetItem *item);
              
              ...
              
              connect(table, &QTableWidget::itemChanged, this, &MainWindow::onTableItemChanged);
              

              Thank you for reply. I got the following error.

              // 
              
              /usr/bin/ld: error: undefined symbol: MainWindow::onTableItemChanged(QTableWidgetItem*)
              >>> referenced by moc_mainwindow.cpp:74
              >>>               moc_mainwindow.o:(MainWindow::qt_static_metacall(QObject*, QMetaObject::Call, int, void**))
              clang++: error: linker command failed with exit code 1 (use -v to see invocation)
              *** [test] Error code 1
              
              // mainwindow.cpp
              

              connect(table, &QTableWidget::itemChanged, this, &MainWindow::onTableItemChanged);

              void MainWindow::onTableitemChanged(QTableWidgetItem *item)
              {
              qDebug() << item->text() << endl ;
              }

              // mainwindow.h
              
              
              void onTableItemChanged(QTableWidgetItem *item);
              
              jsulmJ Offline
              jsulmJ Offline
              jsulm
              Lifetime Qt Champion
              wrote on last edited by jsulm
              #6

              @masayoshi said in QObject::connect: No such signal QTableWidget::itemChanged(QTableWidgetItem *item):

              void MainWindow::onTableitemChanged(QTableWidgetItem *item)

              it should be Item not item:

              onTableItemChanged
              

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

              M 1 Reply Last reply
              2
              • jsulmJ jsulm

                @masayoshi said in QObject::connect: No such signal QTableWidget::itemChanged(QTableWidgetItem *item):

                void MainWindow::onTableitemChanged(QTableWidgetItem *item)

                it should be Item not item:

                onTableItemChanged
                
                M Offline
                M Offline
                masayoshi
                wrote on last edited by
                #7

                @jsulm said in QObject::connect: No such signal QTableWidget::itemChanged(QTableWidgetItem *item):

                @masayoshi said in QObject::connect: No such signal QTableWidget::itemChanged(QTableWidgetItem *item):

                void MainWindow::onTableitemChanged(QTableWidgetItem *item)

                it should be Item not item:

                onTableItemChanged
                

                Thank you! It works.

                1 Reply Last reply
                1

                • Login

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