How to change QTableWidget specified column values to a format Decimal/Hexa using QRadioButton format Selection 1. Decimal 2. Hexa Decimal
-
Hi, I am new to Qt. Here my concern is I am having QTableWidget with 4 columns in that I want to change the values of a particular column to Hexa decimal format from decimal format using QRadioButton selection (1. Decimal 2. Hexa Decimal) while the QTableWidget column is continuously updating with values from an external source.
Here I can update the QTableWidget column cells format from the current cells(assume 100th cell) using the QRadioButtom selection when selected, but I can't update the previous cells of the column with the selected format. Please advise how to do it.
-
Use a QStyledItemDelegate and format the number depending on your checkbox state. Use the search function to check for examples on how to use a QStyledItemDelegate - this is discussed more than once a week.
-
I hope I can't use QStyledItemDelegate with the QTableWiget and only can do with QTableView.
-
I hope I can't use QStyledItemDelegate with the QTableWiget and only can do with QTableView.
@VigneshSaras said in How to change QTableWidget specified column values to a format Decimal/Hexa using QRadioButton format Selection 1. Decimal 2. Hexa Decimal:
with the QTableWiget and only can do with QTableView.
QTableWidget is derived from QTableView...
-
Hi, Christian thanks for your advise. Now I solved it using the QStyledItemDelegate. Another thing I have to change a column values based on another column value, how to do it?
-
Hi, Christian thanks for your advise. Now I solved it using the QStyledItemDelegate. Another thing I have to change a column values based on another column value, how to do it?
@VigneshSaras said in How to change QTableWidget specified column values to a format Decimal/Hexa using QRadioButton format Selection 1. Decimal 2. Hexa Decimal:
Another thing I have to change a column values based on another column value, how to do it?
If the destination column's value can be calculated on demand override the model's
data()
and return the computed value from the other column's value there. Or override model'ssetData()
and set the value of the computed column when the value in the other column is altered. Both of these require subclassing the model, which is easy when using aQTableView
but I don't think it is possible in aQTableWidget
, which has its own internal model. Maybe it is possible to insert aQAbstractProxyModel
between the widget and its model, I don't know.The alternative is to place a slot of the model's
dataChanged()
signal and set the desired value on the computed column when the other column's value is updated. You may also need to deal with a new row being inserted. This should work on aQTableWidget
too.