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. QTableWidget add parameters to slot

QTableWidget add parameters to slot

Scheduled Pinned Locked Moved Unsolved General and Desktop
4 Posts 2 Posters 389 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.
  • T Offline
    T Offline
    Thomas 63
    wrote on last edited by Thomas 63
    #1

    Hello all

    I have a tablewidget and i want to add two parameters to itemClicked().
    The original Slot works fine:
    *.h

        void on_tbl_suche_itemClicked(QTableWidgetItem *item);
    
    

    *.cpp

    void MainWindow::on_tbl_suche_itemClicked(QTableWidgetItem *item){
        cout << "Hello" << endl;
    }
    

    But if I add parameters

    *.h

        void on_tbl_suche_itemClicked(QTableWidgetItem *item, Kurve kurve, Pumpe_o pumpe);
    
    

    *.cpp

    void MainWindow::on_tbl_suche_itemClicked(QTableWidgetItem *item, Kurve kurve, Pumpe_o pumpe){
        cout << "Hello" << endl;
    }
    

    I receive the error message

    QMetaObject::connectSlotsByName: No matching signal for on_tbl_suche_itemClicked(QTableWidgetItem*,Kurve,Pumpe_o)
    

    How can I make the signal/slot work with additional parameters?

    Thanks in advance
    Thomas

    JonBJ 1 Reply Last reply
    0
    • T Thomas 63

      Hello all

      I have a tablewidget and i want to add two parameters to itemClicked().
      The original Slot works fine:
      *.h

          void on_tbl_suche_itemClicked(QTableWidgetItem *item);
      
      

      *.cpp

      void MainWindow::on_tbl_suche_itemClicked(QTableWidgetItem *item){
          cout << "Hello" << endl;
      }
      

      But if I add parameters

      *.h

          void on_tbl_suche_itemClicked(QTableWidgetItem *item, Kurve kurve, Pumpe_o pumpe);
      
      

      *.cpp

      void MainWindow::on_tbl_suche_itemClicked(QTableWidgetItem *item, Kurve kurve, Pumpe_o pumpe){
          cout << "Hello" << endl;
      }
      

      I receive the error message

      QMetaObject::connectSlotsByName: No matching signal for on_tbl_suche_itemClicked(QTableWidgetItem*,Kurve,Pumpe_o)
      

      How can I make the signal/slot work with additional parameters?

      Thanks in advance
      Thomas

      JonBJ Offline
      JonBJ Offline
      JonB
      wrote on last edited by
      #2

      @Thomas-63
      At present you seem to be using the "auto-connect" feature from Qt Designer of naming your slot on_tbl_suche_itemClicked and having that auto-connect to a widget named tbl_suche.

      You won't be able to start on passing your own parameters until you write your own connect() statement in code which you can alter. Start by getting the normal itemClicked signal/slot (without your own parameters) working with your own explicit connect(). Then come back for help on C++ lambdas, which you will need to pass your parameters. Do not use the old-style SIGNAL/SLOT() macros in your connect()s, read and follow the patterns in https://wiki.qt.io/New_Signal_Slot_Syntax, where it also shows lambdas for slots when you are ready.

      1 Reply Last reply
      2
      • T Offline
        T Offline
        Thomas 63
        wrote on last edited by
        #3

        Wow, this seems complicated.

        Maybe it is easier to retrieve the needed parameters within the standard slot...

        Thank you anyway, JonB!

        JonBJ 1 Reply Last reply
        0
        • T Thomas 63

          Wow, this seems complicated.

          Maybe it is easier to retrieve the needed parameters within the standard slot...

          Thank you anyway, JonB!

          JonBJ Offline
          JonBJ Offline
          JonB
          wrote on last edited by
          #4

          @Thomas-63
          Sooner or later, you will need to change over to not use the auto-connect and do your own connect()s anyway. And use the new style, not the SIGNAL/SLOT() macros. And then you will be able to use lambdas and pass your own parameters. Sooner you do so, better it will be for you :)

          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