Get widgets selected with QRubberBand

86 views Asked by At

I'm wondering if there's any way to get all widgets (QLabel specifically) inside a QRubberBand area.

void Widget::mousePressEvent(QMouseEvent *event)
{
    origin = event->pos();
    if (!rubberBand)
        rubberBand = new QRubberBand(QRubberBand::Rectangle, this);
    rubberBand->setGeometry(QRect(origin, QSize()));
    rubberBand->show();
}

void Widget::mouseMoveEvent(QMouseEvent *event)
{
    rubberBand->setGeometry(QRect(origin, event->pos()).normalized());

    //...do something with the widgets inside
}

void Widget::mouseReleaseEvent(QMouseEvent *event)
{
    rubberBand->hide();
}
0

There are 0 answers