views:

236

answers:

2

How can I show data on QTableWidget and read from data on it with header?

+1  A: 

Hi.

1). Create table with this example code:

filesTable = new QTableWidget(0, 2);
QStringList labels;
labels << tr("File Name") << tr("Size");
filesTable->setHorizontalHeaderLabels(labels);
filesTable->horizontalHeader()->setResizeMode(0, QHeaderView::Stretch);
filesTable->verticalHeader()->hide();
filesTable->setShowGrid(false);

2). Add row:

int row = filesTable->rowCount();
filesTable->insertRow(row);
filesTable->setItem(row, 0, fileNameItem);
filesTable->setItem(row, 1, sizeItem);

Enjoy.

mosg
+1  A: 

This book on Qt is freely available and written by one of the best Qt trainers.
You do need to understand something of the "Qt way" before just jumping in and clicking in the layout designer.

Martin Beckett