Hi to all!
I am facing a problem of retrieving all items from a given column of a QTableWidget to a QComboBox. The problem itself appears when I diplay the retrieved items in the ComboBox, because their number get increased. For instance, if I have three rows and four columns, three items are displayed repeately up to twelve in total. I just wanted to have three items corresponding to the number of the rows.
Some precisions:
1- Name is the name of the column fron wich the items should be selected.
2- m_details is my combobox.
3- m_tableau is my TableWidget.
Even the function:
m_details->setDuplicatesEnabled(false);
m_details->setDuplicatesEnabled(false);
To copy to clipboard, switch view to plain text mode
does not solve the problem.
Could someone have a look on my peace of code and propose me an advice? I would be greatefull.
Here is my code:
for(int y = 0; y<m_tableau->rowCount(); y++)
{
for(int x = 0; x<m_tableau->columnCount(); x++)
{
valCol = m_tableau->horizontalHeaderItem(x);
valColConver = valCol->text();
if(valColConver == "Name")
{
valCell = m_tableau->item(y, x);
if(valCell != NULL)
{
valConver = valCell->text();
listeItem.push_back(valConver);
m_details->addItems(listeItem);
valConver.clear();
valColConver.clear();
}
}
}
for(int y = 0; y<m_tableau->rowCount(); y++)
{
for(int x = 0; x<m_tableau->columnCount(); x++)
{
valCol = m_tableau->horizontalHeaderItem(x);
valColConver = valCol->text();
if(valColConver == "Name")
{
valCell = m_tableau->item(y, x);
if(valCell != NULL)
{
valConver = valCell->text();
listeItem.push_back(valConver);
m_details->addItems(listeItem);
valConver.clear();
valColConver.clear();
}
}
}
To copy to clipboard, switch view to plain text mode
Many thanks in advance.
Bookmarks