tags:

views:

51

answers:

1

I have created a QComboBox delegate which I use for a single column of a QTableView (each cell of that column is an individual combobox), the data which I want to display in my combobox returns from the database as a string of id's separated by a ';', my question is, how do I populate my combobox with this data retrieved by the database.

To clarify: the column in question retrieves specific Id's (4 digit strings), sometimes an object may have multiple Id's (separated by ';'), I want to create a combobox for the cells with multiple Id's so the user can select which one they want to work with. My problem seems very simple but I'm a newbie and can't find the simple answer. Anyone have an idea?

A: 

Perhaps something like this would work:

  QString data = "Id01;Id02;Id03;Id04;Id05";
  QStringList list = data.split(";");

  QComboBox *comboBox = new QComboBox;
  comboBox->insertItems(0, list);
Adam
Thanks, this was exactly what I wanted. A simple answer like I thought.
Phil