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 299 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 30 Apr 2021, 08:41 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

    J 1 Reply Last reply 30 Apr 2021, 08:54
    0
    • T Thomas 63
      30 Apr 2021, 08:41

      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

      J Offline
      J Offline
      JonB
      wrote on 30 Apr 2021, 08:54 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 30 Apr 2021, 09:14 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!

        J 1 Reply Last reply 30 Apr 2021, 09:20
        0
        • T Thomas 63
          30 Apr 2021, 09:14

          Wow, this seems complicated.

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

          Thank you anyway, JonB!

          J Offline
          J Offline
          JonB
          wrote on 30 Apr 2021, 09:20 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

          4/4

          30 Apr 2021, 09:20

          • Login

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