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. spinbox input add rows ??
Forum Updated to NodeBB v4.3 + New Features

spinbox input add rows ??

Scheduled Pinned Locked Moved Unsolved General and Desktop
29 Posts 6 Posters 4.3k 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.
  • N Offline
    N Offline
    n-2204
    wrote on 30 Apr 2021, 10:56 last edited by
    #14
     tooll::tool(QWidget* parent)
    : QMainWindow(parent)
      {
      ui.setupUi(this);
     model = new QStandardItemModel(10, 13, this)
     ui.tableView->setModel(model);
     connect(ui.spinBox, SIGNAL(valueChanged(int)), model, 
     SLOT(setTableRows())); 
    }
    void tool::setTable2Rows()
       { 
     int noofrows2 = ui.spinBox_2->value();
     for (int i = 0;i < noofrows2;++i)
      {
          model2->insertRow(i);
        //qDebug() << i;
    }
    }
    

    when i am using new signal/slot why i am getting error
    (Error (active) E0304 no instance of overloaded function)

     connect(ui.spinBox, &QSpinBox::valueChanged, this,&tool::setTableRows);
    connect( sender, &Sender::valueChanged,    receiver, &Receiver::updateValue);
    
    J V 2 Replies Last reply 30 Apr 2021, 11:00
    0
    • N n-2204
      30 Apr 2021, 10:56
       tooll::tool(QWidget* parent)
      : QMainWindow(parent)
        {
        ui.setupUi(this);
       model = new QStandardItemModel(10, 13, this)
       ui.tableView->setModel(model);
       connect(ui.spinBox, SIGNAL(valueChanged(int)), model, 
       SLOT(setTableRows())); 
      }
      void tool::setTable2Rows()
         { 
       int noofrows2 = ui.spinBox_2->value();
       for (int i = 0;i < noofrows2;++i)
        {
            model2->insertRow(i);
          //qDebug() << i;
      }
      }
      

      when i am using new signal/slot why i am getting error
      (Error (active) E0304 no instance of overloaded function)

       connect(ui.spinBox, &QSpinBox::valueChanged, this,&tool::setTableRows);
      connect( sender, &Sender::valueChanged,    receiver, &Receiver::updateValue);
      
      J Offline
      J Offline
      jsulm
      Lifetime Qt Champion
      wrote on 30 Apr 2021, 11:00 last edited by
      #15

      @n-2204 Please post whole error message. Does your tooll class have setTableRows slot? I'm asking because I only see setTable2Rows()

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

      N 1 Reply Last reply 30 Apr 2021, 11:29
      0
      • J jsulm
        30 Apr 2021, 11:00

        @n-2204 Please post whole error message. Does your tooll class have setTableRows slot? I'm asking because I only see setTable2Rows()

        N Offline
        N Offline
        n-2204
        wrote on 30 Apr 2021, 11:29 last edited by
        #16

        yes slot setTablerow() is also there

         void tool::setTableRows()
        { 
        int noofrows = ui.spinBox->value();
        for (int i = 0;i < noofrows;++i)
        {
          model->insertRow(i);
        //qDebug() << i;
        } 
        

        c++ no instance of overloaded function matches the argument list argument types are: (QSpinBox *, <unknown-type>, tooll , void (tool::)())
        Severity Code Description Project File Line Suppression State Detail Description
        Error (active) E0304 no instance of overloaded function "tool::connect" matches the argument list tool C:\User\source\repos\tool\tooll.cpp 265 argument types are: (QSpinBox *, <unknown-type>, tool , void (tool::)())

        1 Reply Last reply
        0
        • N n-2204
          30 Apr 2021, 10:56
           tooll::tool(QWidget* parent)
          : QMainWindow(parent)
            {
            ui.setupUi(this);
           model = new QStandardItemModel(10, 13, this)
           ui.tableView->setModel(model);
           connect(ui.spinBox, SIGNAL(valueChanged(int)), model, 
           SLOT(setTableRows())); 
          }
          void tool::setTable2Rows()
             { 
           int noofrows2 = ui.spinBox_2->value();
           for (int i = 0;i < noofrows2;++i)
            {
                model2->insertRow(i);
              //qDebug() << i;
          }
          }
          

          when i am using new signal/slot why i am getting error
          (Error (active) E0304 no instance of overloaded function)

           connect(ui.spinBox, &QSpinBox::valueChanged, this,&tool::setTableRows);
          connect( sender, &Sender::valueChanged,    receiver, &Receiver::updateValue);
          
          V Offline
          V Offline
          VRonin
          wrote on 30 Apr 2021, 16:06 last edited by
          #17

          @n-2204 said in spinbox input add rows ??:

          tooll::tool(QWidget* parent)

          ????

          What's the name of the class? tooll or tool? looks like a big mess here

          "La mort n'est rien, mais vivre vaincu et sans gloire, c'est mourir tous les jours"
          ~Napoleon Bonaparte

          On a crusade to banish setIndexWidget() from the holy land of Qt

          1 Reply Last reply
          0
          • C Offline
            C Offline
            Christian Ehrlicher
            Lifetime Qt Champion
            wrote on 30 Apr 2021, 16:50 last edited by
            #18

            @n-2204 said in spinbox input add rows ??:

            c++ no instance of overloaded function matches the argument list argument types are: (QSpinBox *, <unknown-type>, tooll , void (tool::)())

            How about taking a single look into the documentation? The problem is exactly explained there.

            Simply writing something without understanding what you're doing doesn't help you at all.

            Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
            Visit the Qt Academy at https://academy.qt.io/catalog

            1 Reply Last reply
            1
            • N Offline
              N Offline
              n-2204
              wrote on 30 Apr 2021, 17:26 last edited by n-2204
              #19

              thanks for sharing ref doc, its done

               connect(ui.spinBox, QOverload<int>::of(&QSpinBox::valueChanged), 
                       this, &tool::setTableRows);
              
              1 Reply Last reply
              0
              • N Offline
                N Offline
                n-2204
                wrote on 3 May 2021, 05:17 last edited by
                #20

                what changes need to do to end the row at end of row, now when i enter value in spinbox row is adding in top but i need to add the row at end how to do ?

                 void tool::setTableRows()
                {
                int noofrows = ui.spinBox->value();
                for (int i = 0;i < noofrows;++i)
                {
                   model->insertRow(i);
                }
                 }
                connect(ui.spinBox, QOverload<int>::of(&QSpinBox::valueChanged), 
                         this, &tool::setTableRows);
                
                J 1 Reply Last reply 3 May 2021, 06:34
                0
                • N n-2204
                  3 May 2021, 05:17

                  what changes need to do to end the row at end of row, now when i enter value in spinbox row is adding in top but i need to add the row at end how to do ?

                   void tool::setTableRows()
                  {
                  int noofrows = ui.spinBox->value();
                  for (int i = 0;i < noofrows;++i)
                  {
                     model->insertRow(i);
                  }
                   }
                  connect(ui.spinBox, QOverload<int>::of(&QSpinBox::valueChanged), 
                           this, &tool::setTableRows);
                  
                  J Offline
                  J Offline
                  jsulm
                  Lifetime Qt Champion
                  wrote on 3 May 2021, 06:34 last edited by
                  #21

                  @n-2204 https://doc.qt.io/qt-5/qabstractitemmodel.html#insertRow
                  "Inserts a single row before the given row in the child items of the parent specified".
                  So, what do you think should you pass as row to insertRow to add at the end of the table?

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

                  J 1 Reply Last reply 3 May 2021, 08:00
                  1
                  • J jsulm
                    3 May 2021, 06:34

                    @n-2204 https://doc.qt.io/qt-5/qabstractitemmodel.html#insertRow
                    "Inserts a single row before the given row in the child items of the parent specified".
                    So, what do you think should you pass as row to insertRow to add at the end of the table?

                    J Offline
                    J Offline
                    JonB
                    wrote on 3 May 2021, 08:00 last edited by
                    #22

                    @n-2204

                    @jsulm said in spinbox input add rows ??:

                    @n-2204 https://doc.qt.io/qt-5/qabstractitemmodel.html#insertRow
                    "Inserts a single row before the given row in the child items of the parent specified".
                    So, what do you think should you pass as row to insertRow to add at the end of the table?

                    Further to @jsulm. insertRow() says

                    Note: This function calls the virtual method insertRows.

                    And in the docs for insertRows, immediately adjacent to insertRow, if you read it it actually tells you what to pass so that

                    the rows are appended to any existing rows

                    Please take the time to read docs....

                    1 Reply Last reply
                    2
                    • N Offline
                      N Offline
                      n-2204
                      wrote on 3 May 2021, 12:43 last edited by n-2204 5 Mar 2021, 13:02
                      #23

                      how can i set value of a spinbox and also edittable for user ?

                       void tool::setTable2Rows()
                       {
                      QAbstractItemModel* table2 = ui.tableView_2->model();
                      int rows2 = ui.spinBox_2->value();
                        ui.spinBox->setValue(10);//this is not working
                        model2->setRowCount(rows2);
                      }
                      

                      if i setvalue 10 then that no. of rows should be there

                      J 1 Reply Last reply 3 May 2021, 13:22
                      0
                      • N n-2204
                        3 May 2021, 12:43

                        how can i set value of a spinbox and also edittable for user ?

                         void tool::setTable2Rows()
                         {
                        QAbstractItemModel* table2 = ui.tableView_2->model();
                        int rows2 = ui.spinBox_2->value();
                          ui.spinBox->setValue(10);//this is not working
                          model2->setRowCount(rows2);
                        }
                        

                        if i setvalue 10 then that no. of rows should be there

                        J Offline
                        J Offline
                        JonB
                        wrote on 3 May 2021, 13:22 last edited by
                        #24

                        @n-2204 said in spinbox input add rows ??:

                        ui.spinBox->setValue(10);//this is not working

                        Don't what you mean. "Not working" could indicate anything. I imagine this works perfectly well.

                        how can i set value of a spinbox and also edittable for user ?

                        if i setvalue 10 then that no. of rows should be there

                        Don't know what these mean either.

                        1 Reply Last reply
                        0
                        • N Offline
                          N Offline
                          n-2204
                          wrote on 3 May 2021, 13:24 last edited by
                          #25

                          not working means value is not set to 10

                          and when i setvalue as 10 , 10 rows should be there in my table
                          also when user change the spinbox value to 11 or 8 no. of rows in table should update

                          J 1 Reply Last reply 3 May 2021, 13:42
                          0
                          • N n-2204
                            3 May 2021, 13:24

                            not working means value is not set to 10

                            and when i setvalue as 10 , 10 rows should be there in my table
                            also when user change the spinbox value to 11 or 8 no. of rows in table should update

                            J Offline
                            J Offline
                            JonB
                            wrote on 3 May 2021, 13:42 last edited by
                            #26

                            @n-2204 said in spinbox input add rows ??:

                            not working means value is not set to 10

                            What value is not set to 10? You can see what it sets:

                            ui.spinBox->setValue(10);
                            

                            I would bet my bottom $ that it does exactly that.

                            and when i setvalue as 10 , 10 rows should be there in my table

                            Your code has

                            model2->setRowCount(rows2);
                            

                            so that is what it does.

                            also when user change the spinbox value to 11 or 8 no. of rows in table should update

                            Which spinbox? Only if you call the code to set the rows when the spin value changes, and only if the code is correct. Which i have to say does not look like the case for the 4 lines of code you have shown...

                            1 Reply Last reply
                            0
                            • N Offline
                              N Offline
                              n-2204
                              wrote on 3 May 2021, 14:20 last edited by
                              #27

                              code:

                               tool::tool(QWidget* parent)
                              : QMainWindow(parent)
                              {
                              ui.setupUi(this);
                              model = new QStandardItemModel(0, 13, this);//row*col
                              model2 = new QStandardItemModel(0, 19, this)
                              ui.spinBox->setValue(10);
                              ui.spinBox_2->setValue(10);
                              

                              using this in spinbox value is 10 but the same no. of rows is not updated in my table
                              so when i set value in spinbox same no. of rows should be added in my table
                              and when user change value in spinbox row should update (that is happening)

                               connect(ui.spinBox, QOverload<int>::of(&QSpinBox::valueChanged), 
                                       this, &tool::setTableRows);
                               connect(ui.spinBox_2, QOverload<int>::of(&QSpinBox::valueChanged),
                                       this, &tool::setTable2Rows);
                               } 
                              void tool::setTableRows()
                              {
                              QAbstractItemModel* table1 = ui.tableView->model();
                              int rows = ui.spinBox->value();
                              model->setRowCount(rows);
                               } 
                              
                               void tool::setTable2Rows()
                              {
                              QAbstractItemModel* table2 = ui.tableView_2->model();
                              int rows2 = ui.spinBox_2->value();
                              model2->setRowCount(rows2);
                              }
                              
                              J 1 Reply Last reply 3 May 2021, 19:30
                              0
                              • N n-2204
                                3 May 2021, 14:20

                                code:

                                 tool::tool(QWidget* parent)
                                : QMainWindow(parent)
                                {
                                ui.setupUi(this);
                                model = new QStandardItemModel(0, 13, this);//row*col
                                model2 = new QStandardItemModel(0, 19, this)
                                ui.spinBox->setValue(10);
                                ui.spinBox_2->setValue(10);
                                

                                using this in spinbox value is 10 but the same no. of rows is not updated in my table
                                so when i set value in spinbox same no. of rows should be added in my table
                                and when user change value in spinbox row should update (that is happening)

                                 connect(ui.spinBox, QOverload<int>::of(&QSpinBox::valueChanged), 
                                         this, &tool::setTableRows);
                                 connect(ui.spinBox_2, QOverload<int>::of(&QSpinBox::valueChanged),
                                         this, &tool::setTable2Rows);
                                 } 
                                void tool::setTableRows()
                                {
                                QAbstractItemModel* table1 = ui.tableView->model();
                                int rows = ui.spinBox->value();
                                model->setRowCount(rows);
                                 } 
                                
                                 void tool::setTable2Rows()
                                {
                                QAbstractItemModel* table2 = ui.tableView_2->model();
                                int rows2 = ui.spinBox_2->value();
                                model2->setRowCount(rows2);
                                }
                                
                                J Offline
                                J Offline
                                JonB
                                wrote on 3 May 2021, 19:30 last edited by JonB 5 Mar 2021, 19:37
                                #28

                                @n-2204 said in spinbox input add rows ??:

                                using this in spinbox value is 10 but the same no. of rows is not updated in my table

                                If I understand correctly.

                                At the time you call

                                ui.spinBox->setValue(10);
                                

                                you have not yet done the

                                 connect(ui.spinBox, QOverload<int>::of(&QSpinBox::valueChanged), 
                                         this, &tool::setTableRows);
                                

                                So if you are expecting the slot setTableRows() to be called to actually create rows during the setValue(), it won't be. Why should it?

                                Either connect the signals before setting the values, or call the slots explicitly first time before you start out.

                                Is that what you mean?

                                N 1 Reply Last reply 4 May 2021, 04:26
                                1
                                • J JonB
                                  3 May 2021, 19:30

                                  @n-2204 said in spinbox input add rows ??:

                                  using this in spinbox value is 10 but the same no. of rows is not updated in my table

                                  If I understand correctly.

                                  At the time you call

                                  ui.spinBox->setValue(10);
                                  

                                  you have not yet done the

                                   connect(ui.spinBox, QOverload<int>::of(&QSpinBox::valueChanged), 
                                           this, &tool::setTableRows);
                                  

                                  So if you are expecting the slot setTableRows() to be called to actually create rows during the setValue(), it won't be. Why should it?

                                  Either connect the signals before setting the values, or call the slots explicitly first time before you start out.

                                  Is that what you mean?

                                  N Offline
                                  N Offline
                                  n-2204
                                  wrote on 4 May 2021, 04:26 last edited by
                                  #29

                                  @JonB said in spinbox input add rows ??:

                                  @n-2204 said in spinbox input add rows ??:

                                  using this in spinbox value is 10 but the same no. of rows is not updated in my table

                                  If I understand correctly.

                                  At the time you call

                                  ui.spinBox->setValue(10);
                                  

                                  you have not yet done the

                                   connect(ui.spinBox, QOverload<int>::of(&QSpinBox::valueChanged), 
                                           this, &tool::setTableRows);
                                  

                                  So if you are expecting the slot setTableRows() to be called to actually create rows during the setValue(), it won't be. Why should it?

                                  Either connect the signals before setting the values, or call the slots explicitly first time before you start out.
                                  ok understood
                                  Is that what you mean?
                                  yes
                                  thanks

                                  1 Reply Last reply
                                  0

                                  23/29

                                  3 May 2021, 12:43

                                  • Login

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