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. Change value in table view in spin box
QtWS25 Last Chance

Change value in table view in spin box

Scheduled Pinned Locked Moved Unsolved General and Desktop
tablviewc++qt 5.7databasespinbox
4 Posts 2 Posters 1.8k 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.
  • R Offline
    R Offline
    ronyNS
    wrote on 8 Sept 2016, 16:59 last edited by
    #1

    Hello
    I am trying to change a value in a table view with spin box.When i change the value in a spin box the value present in table view should change accordingly.
    I have a database displayed in the table view. I just want to connect a spinbox to a related value in the table view and update when spinbox value is changed.
    Thank you.

    1 Reply Last reply
    0
    • V Offline
      V Offline
      VRonin
      wrote on 8 Sept 2016, 17:01 last edited by
      #2

      What model are you using? is the index of the affected value constant?

      "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

      R 1 Reply Last reply 8 Sept 2016, 17:12
      0
      • V VRonin
        8 Sept 2016, 17:01

        What model are you using? is the index of the affected value constant?

        R Offline
        R Offline
        ronyNS
        wrote on 8 Sept 2016, 17:12 last edited by
        #3

        @VRonin
        Im using QSqlQueryModel and yes the index is constant.

        1 Reply Last reply
        0
        • V Offline
          V Offline
          VRonin
          wrote on 8 Sept 2016, 17:42 last edited by VRonin 9 Aug 2016, 17:43
          #4
          // QSpinBox* mySpinBox;
          //QSqlQueryModel *model;
          // int rowIndex,colIndex;
          
          QObject::connect(mySpinBox, static_cast<void (QSpinBox::*)(int)>(&QSpinBox::valueChanged),[model,rowIndex,colIndex](int val)->void{
          model->setValue(model->index(rowIndex,colIndex),val);
          });
          

          "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
          2

          1/4

          8 Sept 2016, 16:59

          • Login

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