
Originally Posted by
d_stranz
You can't share the same QTableWidgetItem among tables, because the QTableWidget takes ownership of the item.
If you convert to QTableView and implement a QAbstractItemModel to hold the information you want to display, then you can use the same model instance in as many tables as you want. Each view can have a completely independent sort of the model. When you edit, you are editing the model, not the view of the model, so changes to the model are reflected in every view.
OK, let's see if I understand, I create a model that for example includes the Player Name, that would go in every Table Tab and will be the same so it's reflected in every Tab (view). Now I can add more to that base model right like sub-classes, right? So they all have Player Name but each Tab (view) has it's own Items.

Originally Posted by
d_stranz
There's essentially no difference. Both signals are emitted when the data in the cell changes. In one case, the widget is telling you the cell indexes, which you can use to retrieve the QTableWidgetItem for that cell; in the other case, the widget is telling you the QTableWidgetItem pointer, which you can use to retrieve the cell indexes where it lives.
Yeah, I used itemChanged without arguments and it worked the same as cellChanged:
void MainWindow::on_tableWidget_Players_itemChanged()
{
ui
->tableWidget_Players
->item
(0,
1)->setData
(Qt
::DisplayRole,
QVariant(QString::number((((ui
->tableWidget_Players
->item
(0,
0))->text
().
toFloat()) / 3),
'f',
1)));
}
void MainWindow::on_tableWidget_Players_itemChanged()
{
ui->tableWidget_Players->item(0,1)->setData(Qt::DisplayRole, QVariant(QString::number((((ui->tableWidget_Players->item(0,0))->text().toFloat()) / 3),'f',1)));
}
To copy to clipboard, switch view to plain text mode
But could you give me an example of how should the QTableWidgetItem pointer go on itemChanged(QTableWidgetItem * item), I don't know how and can't find examples in Google.
Thanks for your time.
Bookmarks