PDA

View Full Version : Rubberband painting on multiselection in a list view



SkripT
16th March 2006, 08:51
Hi all, I'm using Qt4.1.0 on WindowsXp. I have a QListWidget that accepts multiselections of items. I call to QAbstractItemView::setSelectionMode(QAbstractItemV iew::MultiSelection) and the items are multi selected but no rubberband is painted to see which items are you selecting and it's a bit annoying. Does anybody knows a simple way to show the rubberband or I am forced to use the QRubberband class. As I remember, in Qt3 the rubberband is shown by default in multiselection mode...

Thanks

wysota
17th March 2006, 13:43
In Qt4 the rubber band is shown only in icon mode. If you want, you can change to icon mode, position the icons from top to bottom and change movement property to static. You'll end up with something close to list mode and a rubber band.

But using a rubber band in list mode doesn't make much sense anyway, because if you drag, you always select a sequence of elements, so you know what you are selecting. This is not true for icons.

Of course you can always subclass or install an event filter and draw the band yourself.

SkripT
17th March 2006, 14:30
wysota, the strange thing is that I have the list in icon mode :confused: That's how I configure it:


llistaFotosPetites = new QListWidget;
llistaFotosPetites -> setViewMode(QListView::IconMode);
llistaFotosPetites -> setIconSize(QSize(TAM_ICON_HOR, TAM_ICON_VER));
llistaFotosPetites -> setFlow(QListView::LeftToRight);
llistaFotosPetites -> setMovement(QListView::Static);
llistaFotosPetites -> setResizeMode(QListView::Adjust);
//llistaFotosPetites -> setLayoutMode(QListView::Batched);
llistaFotosPetites -> setWrapping(true);
llistaFotosPetites -> setTextElideMode(Qt::ElideRight);
//llistaFotosPetites -> setSpacing(8);
llistaFotosPetites -> setGridSize(QSize(TAM_GRID_HOR, TAM_GRID_VER));
llistaFotosPetites -> setUniformItemSizes(true);
llistaFotosPetites -> setSelectionMode(QAbstractItemView::ExtendedSelect ion);
llistaFotosPetites -> setFrameShape(QFrame::NoFrame);

Do you know why the rubberband doesn't appear?

wysota
17th March 2006, 14:42
Change ExtendedSelection to MultiSelection.

SkripT
17th March 2006, 16:42
Change ExtendedSelection to MultiSelection.

I've tried it in both modes but the rubberband doesnt' appears

wysota
17th March 2006, 16:49
Hmm... strange. It works for me (4.1.1) :) Try making a simple dialog in Designer which consists of a list widget with some items and check (under preview) if you see a rubber band.

SkripT
17th March 2006, 17:05
You're right wysota with designer appears the rubberband, strange :confused: It's like if a option that I've activated disables the rubberband or something. I attach an image to show you that the multiselections are enabled...

SkripT
17th March 2006, 17:12
Maybe the problem could be that the list widget is inside a tab widget? :confused:

wysota
17th March 2006, 17:17
No, not likely. You can take a look at Qt sources to see if there are any requirements for the band to be drawn (in QListView class).

SkripT
18th March 2006, 10:01
Finally I've found where it disables the rubberband: fixing the movement to static :eek: Very strange, I think that both things have not strictly relationship. A bug of Qt? Could anybody tell me if with the new version (4.1.1) it also locks the rubberband?

wysota
19th March 2006, 11:13
In 4.1.1 with static movement the rubber band is drawn.