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. Changing content of part of QTableWidget after editiong
Forum Updated to NodeBB v4.3 + New Features

Changing content of part of QTableWidget after editiong

Scheduled Pinned Locked Moved Unsolved General and Desktop
qtablewidgetqitemdelegateqmodelidex
4 Posts 4 Posters 1.9k 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.
  • M Offline
    M Offline
    michelson
    wrote on last edited by michelson
    #1

    Hello guys,
    it problably due to my lack of understanding the Qt mechanism of Item-Model View i encountered a problem:
    lets say you have a 2-column QTableWidget (with custom QItemDelegate), second column depends of a choice in the first column.
    Eg,:
    in first column you have combo box with either voltage or current as a choice so the sencond column will have values available either {1V, 3V, 5V} or {1A, 3A,7A}.
    When i change values in second column everything is ok since they are already set, however when i change the type in first column (eg.: voltage to currend) i want the value in the second column to change to the corresponding one (eg.: first column had 5V chosen so i want them to change to 7A).
    I assumed i had to reimplement QItemDelegate::setModelData(...) however i failed to achive above behaviour. Can you give me a sample or a link to a simple tutorial (i dont find Qt documentation helpfull, i mean descriptions are fine but the whole mechanism is not clear for me i guess)

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

      You should rather implement your own model based on QAbstractTableModel. That way you'll be able to handle your use case more easily.

      I'd recommend reading "C++ GUI Programming with Qt 4" from Jasmin Blanchette and Mark Summerfield referenced here. Even if it's for Qt 4, it's still valid and a very good book and covers custom models very well.

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0
      • Q Offline
        Q Offline
        qt_5.x
        wrote on last edited by
        #3

        help me
        link >>>
        https://forum.qt.io/topic/62102/help-webkit-help

        1 Reply Last reply
        -1
        • kshegunovK Offline
          kshegunovK Offline
          kshegunov
          Moderators
          wrote on last edited by
          #4

          @michelson said:
          Hello,

          I assumed i had to reimplement QItemDelegate::setModelData(...)

          I think this should suffice for your case. You can of course always create your own model as @SGaist suggested. As for your request for additional material:

          • Here is an overview of the model-view framework
          • A simple spinbox delegate example
          • Icons example that uses delagets

          I hope this helps.
          Kind regards.

          Read and abide by the Qt Code of Conduct

          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