Jūs esate

Problem with QTableWidgetItem and QTableWidget

I have a small problem with QTableWidget and QTableWidgetItem. I have a QHash<QString, QString> downloadQueue. There is at least one entry inside downloadQueue. The point is, that items inside downloadQueue are not added to the QTableWidget. I don't know  why.
void MDIChildWindow::regenerateTabs() {


int row = 0;

// Added line


// End of added

foreach(QString key, downloadQueue.keys()) {

QTableWidgetItem *download = new QTableWidgetItem(key);

download->setFlags(Qt::ItemIsEnabled | Qt::ItemIsSelectable);

m_ui->tableWidgetDownloadQueue->setItem(row, 0, download);

QTableWidgetItem *location = new QTableWidgetItem(downloadQueue.value(key) + "/" + key);

location->setFlags(Qt::ItemIsEnabled | Qt::ItemIsSelectable);

m_ui->tableWidgetDownloadQueue->setItem(row++, 1, location);



Inside foreach() key and downloadQueue.value(key) returns valid values (QStrings).

Do you have any ideas why this is not working???


I found a solution. The problem is, that you need to add a number of entries: