I haven't tested with QTableWidget, but I know that with QListWidget there's a much better solution than using QListWidget::itemChanged and trying to block all the signals when adding/changing colors/setting flags, and doing anything else that "changes" the item.
Try this...
connect(ui.pTblItems->itemDelegate(), &QAbstractItemDelegate::commitData, this, &MyWidget::OnTblItemsCommitData);
connect(ui.pTblItems->itemDelegate(), &QAbstractItemDelegate::commitData, this, &MyWidget::OnTblItemsCommitData);
To copy to clipboard, switch view to plain text mode
Then implement the slot like this...
void MyWidget
::OnTblItemsCommitData(QWidget* pLineEdit
) {
QString strNewText
= reinterpret_cast<QLineEdit
*>
(pLineEdit
)->text
();
int nRow = ui.pTblItems->currentRow();
// do whatever you need here....
}
void MyWidget::OnTblItemsCommitData(QWidget* pLineEdit)
{
QString strNewText = reinterpret_cast<QLineEdit*>(pLineEdit)->text();
int nRow = ui.pTblItems->currentRow();
// do whatever you need here....
}
To copy to clipboard, switch view to plain text mode
Like I said... I only tried this for QListWidget, so who knows it might not work at all for the table widget, but the two classes are pretty similar so I wouldn't be surprised if it worked. You might have to tweak that code a bit to make it table widget specific.
Bookmarks