Re: Item Delegate Painting
Based on what I know the default behaviours of all the views is like you describe it, so there is no need for a custom delegate. Just enable drag & drop for your model and view and maybe reimplement dropEvent() to pop up the replacement dialog before calling the base class implementation.
Re: Item Delegate Painting
From a test a did in the past I recall that there wasn't a "guide" (the red line) indicating where the item was going to be placed, so I figured I'd need a delegate to do that.
I actually want it be be like in Excel when you move rows around. If you drag a row in between you get a really wide H shape on the division between the rows in a greyed out colour. I want that in say red, and possibly even slide what's below the insertion point down a row height as a really clear indication of where it's going, kind of like the way dock widgets slide apart to make a space.
The software project I'm working on is (intended to be) a better version of a system I supported a few years ago. Whilst I'm working on the re-invention I want to make the user experience as easy and obvious as possible.
I'll try getting the drag and drop done first and see how that behaves, then attempt to implement this delegate if it doesn't work.
If I do need the delegate, how do I work around my original question? Do I need to loop through each QModelIndex, get the data() member then paint the text manually onto the QPainter context provided, essentially managing the entire rendering process?
Maybe I just need to look at the QItemDelegate implementation.
Re: Item Delegate Painting
Quote:
Originally Posted by
stevey
From a test a did in the past I recall that there wasn't a "guide" (the red line) indicating where the item was going to be placed, so I figured I'd need a delegate to do that.
There is, just set the showDropIndicator property to true.
Quote:
I actually want it be be like in Excel when you move rows around. If you drag a row in between you get a really wide H shape on the division between the rows in a greyed out colour. I want that in say red, and possibly even slide what's below the insertion point down a row height as a really clear indication of where it's going, kind of like the way dock widgets slide apart to make a space.
In that case delegates won't help you. You have to implement it in the view. The delegate renders a single item, not "a row of items" or "something around items".