Will03uk
Will03uk

Reputation: 3444

How do I use the QTable? Adding, editing, removing and retrieving rows

How do you use the QTable object. I have searched the internet and the examples don't really seem to make sense. Do you just create a new row within the extended class. It all seems fussing. How do you retreive, edit and delete rows. Is there any extensions that could be used like

QRowObject *row = table->add("Main Title");
row->addSubColumnText("Second column");
otherRow = table->getRowByIndex(table->selectedIndex);
otherRow.remove;

How would any implement that?

Any extra information needed just ask.

Upvotes: 1

Views: 2328

Answers (1)

sje397
sje397

Reputation: 41812

QTable is pretty old. You might be looking for QTableWidget. If you want to get into the whole 'Model-View' arch thing, look into QTableView.

// inside e.g. a QMainWindow, parent could be 'this'
QTableWidget *widget = new QTableWidget(parent); 
// add to layout etc, then:

QStringList headerLabels;
headerLabels << "First Column" << "Second Column";
widget->setHorizontalHeaderLabels(headerLabels);
// here you would add data, then:
widget->removeRow(table->currentRow());

Upvotes: 3

Related Questions