Unsolved How to update a table's combox's display effectively??
-
I have created a QTableWidget and used a delegate and QModel to contain some combobox, and the combobox works.
But there are limitation between columns. For example, if I change the data in column 1, the data in column 2 will change with it. Note: column 1 and 2 are both comboxs.
So when I change the data in column1, I will change the data in column 2 in the function setData() of the model class. After change data, I emit a dataChanged(index, index, {role});
But the result is not satisfatory. Column 2's data do not change immediately, it won't change untill I click the mouse or I minimize the window and restore the window.
I have tried the update() funtion and it didn't work.
I guess when I change column 1's combobox, it has the focus or something that stops the table painting the new data.
What must I do to get it work correctly? -
Since you're using item widgets you have to connect to dataChanged() and call update() for the corresponding combobox by yourself.
-
I have tried to call the table's update() immediately after setDate, but it did'nt work?
You mean I should connect dataChanged() to updata(), not just emit it?
Which update() I should connect dataChanged() to? combobox's update()? -
How do you fill the data of your comboboxes? Not via the model.
-
I fill the combobox in the createEditor function of the delegate, such as:
QComboBox *cb = new QComboBox(parent); cb->addItem(QString("Low")); cb->addItem(QString("High")); return cb;
-
I will change the data in column 2 in the function setData() of the model class. After change data, I emit a dataChanged(index, index, {role});
Could you show this part of the code?