Question

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.

Was it helpful?

Solution

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);
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top