Changing content of part of QTableWidget after editiong
-
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-columnQTableWidget
(with customQItemDelegate
), 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 reimplementQItemDelegate::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) -
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.
-
help me
link >>>
https://forum.qt.io/topic/62102/help-webkit-help -
@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.