jeudi 28 septembre 2017

How to move rows in Qt (in QTableWidget)

It's really a shame that Qt devs skipped this really important part of a table... moving rows (probably the selected ones) with checks for collision and support for selections with gaps - now one has to implement it himself.

Luckily I spent pretty much the whole day creating such, self-contained function that can be easily modified to move anything related to tables/lists (currently it moves selected items - second line). And a more interesting part, I was able to easily (with about 3 lines more) add support for a direction argument instead of a separate function.

I haven't thought about it, but moving by more than 1 item at a time could be possible aswell - though I have no need for that.

Any suggestions and bug-testing is appreciated ~~enjoy.

Aucun commentaire:

Enregistrer un commentaire