PDA

View Full Version : How to set data from combobox delegate into 2 cells?



andsun
18th May 2015, 12:28
Hi all,

I have a problem figuring out how to set numeric data into another cell, the first left one of the current cell.
Code is like the spinbox example

My code holds the combobox delegate, it is connected to some column cells.
When I enter to select item from the combobox and then leaving, the text gets pasted into the cell -fine. However I want to save a numeric value, the combobox index into another cell.
Here lays my problem I don't know how to get the cell to the left of the current cell, and how to be able to paste the index number to the cell.


any ideas?

anda_skoa
19th May 2015, 20:46
When your delegate's editor finishes editing, the delegate's setModelData() is being called to store the data into the model.

You can chose any method of working with the mode in there, including calling the model's setData() for more than one index.

Cheers,
_

andsun
20th May 2015, 15:32
Hi anda_skoa, thks for reply.

As you suggests, my solution is to put it in the setModelData
From the input parameters I simply use the model and index.

QModelIndex indx = model->index(index.row(), index.column() -1);
model->setdata(indx, comboData->currentIndex(), Qt::EditRole);

Thks
/anders