[Interest] implementing rows reordering in QSortFilterProxyModel

Giuseppe D'Angelo giuseppe.dangelo at kdab.com
Mon Oct 12 21:46:21 CEST 2020


Il 12/10/20 15:31, Александр Иваш ha scritto:
> Is there any example for re-ordering of QTableView entries implemented
> in QSortFilterProxyModel (ideally drag-n-drop-driven)? If not, what is
> the best way to implement it? I'm thinking about implementing
> reordering as 'custom sorting' - but it will require me to collect all
> the QModelIndex-es in the separate list (which can be then reordered
> and used for custom sorting). 

Just to make sure I understood, do you need a proxy model that allows to 
reorder the rows of a given source model via DND?

> The issue with such approach is that
> QModelIndex-es are short-living and I need to track its lifetime
> somehow.... Any better ideas?

QPersistentModelIndex. But it sounds like it's not _really_ needed, you 
need a way to map integers (row numbers from the source model) into 
other integers (row numbers after the proxy).

HTH,

-- 
Giuseppe D'Angelo | giuseppe.dangelo at kdab.com | Senior Software Engineer
KDAB (France) S.A.S., a KDAB Group company
Tel. France +33 (0)4 90 84 08 53, http://www.kdab.com
KDAB - The Qt, C++ and OpenGL Experts

-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 4329 bytes
Desc: Firma crittografica S/MIME
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20201012/e4e3ca94/attachment.bin>


More information about the Interest mailing list