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

Qtableview calculation in column

Scheduled Pinned Locked Moved Unsolved General and Desktop
6 Posts 2 Posters 499 Views 1 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 last edited by n-2204
    #1

    c969ca8b-0422-4a9e-9142-c488cfed3c59-image.png
    i have two tables(qtableview)
    so how can i store the column data so i can use everywhere as now done like this

    for (int i = 0, maxI = table1->rowCount();i <= maxI;++i) {
        bool ok1, ok2;
        double n = table1->data(table1->index(i, 5)).toDouble(&ok1);
        double pitch = table1->data(table1->index(i, 4)).toDouble(&ok2);
        if (ok1 && ok2 && pitch && n != 0)
        table1->setData(table1->index(i, 8), (n+2)/pitch);
    }
    how can i store this setdata in some variable so can use in other column calculations ?
    

    also in table2 col 1and 2 combobox based on user input in table1 col1
    so now when user select in table2 as col1 as input 1 col2 input 2 if user select input 2 input 3 so that pitchdiameter ratio of these should result in table2 col3 how to do this?

    JonBJ 1 Reply Last reply
    0
    • N n-2204

      c969ca8b-0422-4a9e-9142-c488cfed3c59-image.png
      i have two tables(qtableview)
      so how can i store the column data so i can use everywhere as now done like this

      for (int i = 0, maxI = table1->rowCount();i <= maxI;++i) {
          bool ok1, ok2;
          double n = table1->data(table1->index(i, 5)).toDouble(&ok1);
          double pitch = table1->data(table1->index(i, 4)).toDouble(&ok2);
          if (ok1 && ok2 && pitch && n != 0)
          table1->setData(table1->index(i, 8), (n+2)/pitch);
      }
      how can i store this setdata in some variable so can use in other column calculations ?
      

      also in table2 col 1and 2 combobox based on user input in table1 col1
      so now when user select in table2 as col1 as input 1 col2 input 2 if user select input 2 input 3 so that pitchdiameter ratio of these should result in table2 col3 how to do this?

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

      @n-2204 said in Qtableview calculation in column:

      also you can in table2 col 1and 2 combobox based on user input in table1 col1
      so now when user select in table2 as col1 as input 1 col2 input 2 if user select input 2 input 3 so that pitchdiameter ratio of these should result in table2 col3 how to do this?

      Maybe someone can understand what you are saying here, but I can't.

      how can i store this setdata in some variable so can use in other column calculations ?

      You just stored it in table1->index(i, 8). So you can retrieve it from table1->index(i, 8).data().

      [BTW: i <= maxI: shouldn't this be i < maxI?]

      1 Reply Last reply
      0
      • N Offline
        N Offline
        n-2204
        wrote on last edited by n-2204
        #3

        in table2 column 1&2 are combobox delegate and values are from table1 column1
        so when user select in table2 column 1 &2 -input1 input2 or input2/3 so in table2 column 3 there will division of column6 table1(pitchdiameter) value (row 1 /row 2 value)
        eg. if in table2 user select input1 input 3 in column1 &2 so now in column 3 result (ratio )is table1 col6 (row 1 /row 3 value)
        if in table2 user select input2 input 3 in column1 &2 so now in column 3 result (ratio )is table1 col6 (row 2/row 3 value)
        if in table2 user select input1 input 2 in column1 &2 so now in column 3 result (ratio )is table1 col6 (row 1/row 2 value)

        1 Reply Last reply
        0
        • N Offline
          N Offline
          n-2204
          wrote on last edited by
          #4

          any suggestions how to do this ??

          JonBJ 1 Reply Last reply
          0
          • N n-2204

            any suggestions how to do this ??

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

            @n-2204
            No, because at least for myself I find your explanation of what you are trying to achieve indecypherably complex! If you want help, can't you rephrase your question to be minimal and much simpler. Unless someone else understands....

            1 Reply Last reply
            0
            • N Offline
              N Offline
              n-2204
              wrote on last edited by n-2204
              #6

              how can i get selection value of combobox delegate from qtableview?

              1 Reply Last reply
              0

              • Login

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