[Qt-interest] QRubberBand and set selection in qlistwidget
Puneet Bisht
pbisht at nivio.com
Tue Aug 11 09:11:24 CEST 2009
hi all,
I am facing a problem in selecting the items in a qlistwidget.
Actually i have a class which inherit qlistwidget and i am showing the items
in icon mode .
here in this custom widget i am showing a rubberband like this :
void MyWidget::mousePressEvent(QMouseEvent *event)
{
origin = event->pos();
if (!rubberBand)
rubberBand = new QRubberBand(QRubberBand::Rectangle, this);
rubberBand->setGeometry(QRect(origin, QSize()));
rubberBand->show();
}
void MyWidget::mouseMoveEvent(QMouseEvent *event)
{
rubberBand->setGeometry(QRect(origin, event->pos()).normalized());
setSelection(QRect(origin,e->pos()).normalized(),QItemSelectionModel::Select);
//setSelection(rubberBand->rect(),QItemSelectionModel::Select );
}
void MyWidget::mouseReleaseEvent(QMouseEvent *event)
{
rubberBand->hide();
}
here all things goes fine but no item is selected .
I am unable to understand why this is happening .
Please help me on this issue .
Thanks in Advance.
More information about the Qt-interest-old
mailing list