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
Forum Updated to NodeBB v4.3 + New Features

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.9k 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.
  • ronyNSR Offline
    ronyNSR Offline
    ronyNS
    wrote on 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
    • VRoninV Offline
      VRoninV Offline
      VRonin
      wrote on 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

      ronyNSR 1 Reply Last reply
      0
      • VRoninV VRonin

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

        ronyNSR Offline
        ronyNSR Offline
        ronyNS
        wrote on last edited by
        #3

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

        1 Reply Last reply
        0
        • VRoninV Offline
          VRoninV Offline
          VRonin
          wrote on last edited by VRonin
          #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

          • Login

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