Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I programmatically commit data from QTableWidget, which contain some items in editing state?

Tags:

qt

How can I autocommit data from QTableWidget, that is in editing state, when I fire some command?

Assume, that there is some grid and data in it (editable thorough delegate that fires QComboBox editor). So, one starting to select option in combo, but do not finish editing, then hit some button, that executes action, that uses data from that combo, but new choise is not committed yet :\

How can I programmatically finish editing in table?

I mean some not strict 'loop all items and finish editing' way, that I consider as bad and ugly.

OOPS: worked too much, so, haven't realised, that there could be only one pending editor at time. Question is still here.

like image 247
Maxim Popravko Avatar asked Feb 27 '23 08:02

Maxim Popravko


1 Answers

There is a protected slot named "commitData" in the tableWidget. You can inherit from tableWidget, then add your own public method (or slot) and send a signal (or simply call commitData method) from there. There is one problem. You'll need to provide the editor object, but tableWidget gives you no way to get the pointer you need. If you're using your own createEditor method, you can save the pointer to the editor somewhere, where your method can get it. It's a hack, but it's the only way i know.

like image 93
KaiSD Avatar answered Apr 29 '23 16:04

KaiSD