PDA

View Full Version : How change the DropIndicator of QAbstractItemView



Wan-Hi
16th March 2006, 22:31
hello everyone.

first, congratulations to this very nice site. i highly appreciate all well organized resources about Qt.

now to my problem: i want to implement a QTableView where only full rows are selectable. of course, this is not hard at all. i also want to enable drag-n-drop of full rows. when dragging full rows, the DropIndicator should not only highlight a single QModelIndex item, but a full row. therefore i wanted to override dragMoveEvent(QDragMoveEvent * event) of QAbstractItemView. unfortunately this "d" field (which i haven't fully understood), which holds the coordinates of the DropIndicator's drawing rectangle, is not accessible because it's private. :( is there another way to manipulate the drawing rectangle of the DropIndicator?


thanks.

wan-hi

wysota
17th March 2006, 14:37
IMO you just need to change QAbstractItemView::SelectionBehavior property to QAbstractItemView::SelectRows. AFAIR this causes both the whole row to be selected and whole row to be indicated while dragging. No need for any custom code.

Wan-Hi
17th March 2006, 21:41
sorry, but you misunderstood. yes, when changing the selection behaviour to QAbstractItemView::SelectRows, the QTableView does select full rows and drags them visually, but it does not change it's DropIndicator behaviour. the DropIndicator still renders frames around single table items, not full rows.

that's why i wanted to override the dropEvent function because that's where the coordinates of the frame to render are generated. unfortunately these values are given to a private member which i get no access to. i'd love to know how other people worked around this problem.

Wan-Hi
20th March 2006, 20:58
has nobody dealt with this problem before?