PDA

View Full Version : QListWidget



Carlsberg
12th October 2012, 05:39
I have a QListWiget that uses a custom item delegate. The list is in wrap mode. The problem is with multiple selection with the mouse. If the drag is enabled, after pressing the mouse and start dragging instead of selecting multiple items the only item selected is being dragged. That's normal because when you click the cursor is on an item. However, the problem is that there is no space between the column so you can start the selection without pressing an item, like for example Windows Explorer.

Is there any way of setting a space between the columns so that when you click you are not clicking on an item?

wysota
12th October 2012, 09:52
You can set the spacing or the grid size of the view.

Carlsberg
12th October 2012, 11:29
I've tried that, what spacing does is actually "padding", so there is more space, but it's not "space between columns", there is still no space where you can press without selecting something, like in Explorer...

I haven't look at the code but I'm afraid that the wrapping thing doesn't leave space between columns, which really sucks, because you can't use only the mouse to do multiple selection when drag&drop is enabled

wysota
12th October 2012, 11:41
No, you are wrong. Spacing is between items. Maybe it is your custom delegate that messes something up. I can easily select and drag many items in the cofiguration you described.

Here is a sample ui file, open it in Designer, preview it and see for yourself.

Carlsberg
12th October 2012, 21:23
Well, I've solved the mystery. You have in there this


listWidget->setFlow(QListView::LeftToRight);

while I need TopToBottom.

If you change to that, you'll see that there is no space between columns... There is instead between rows (when the flow is LeftToRight, the space is both between rows and columns).

And another problem with spacing is that it's in all direction, while I'd like to have only the columns a little apart. This can be fixed using something like


listWidget->setGridSize(QSize(100, 20));

but then again, there is no space between columns.

And another thing, even in the LeftToRight flow, the selection is not correct, it will also selects items OUTSIDE the selection rectangle.

This is pretty messed up... :)

For now I can use gridSize and I can find some space between rows. Thank you

wysota
12th October 2012, 21:45
Well, I've solved the mystery. You have in there this


listWidget->setFlow(QListView::LeftToRight);

while I need TopToBottom.

If you change to that, you'll see that there is no space between columns... There is instead between rows (when the flow is LeftToRight, the space is both between rows and columns).

So? What's wrong with that?


but then again, there is no space between columns.
Subclass and reimplement visualRect().

ali123
17th October 2012, 08:21
nice post/*-*-*-