C++ (Qt)int side = qMin(width(), height());QRegion maskedRegion(width() / 2 - side / 2, height() / 2 - side / 2, side, side, QRegion::Ellipse);setMask(maskedRegion);
C++ (Qt)class QUntouchable : public QRubberBand{ Q_OBJECT public: QUntouchable(QRubberBand::Shape shape, QWidget *parent = NULL) : QRubberBand(shape, parent) { setMouseTracking(true); } ~QUntouchable() {} bool QUntouchable::event(QEvent *ev) { if (ev->type() == QEvent::MouseMove) { QMouseEvent *mev = (QMouseEvent*)ev; QRegion newmask = QRegion(this->rect()) - QRegion(mev->x(), mev->y(), 1, 1); setMask(newmask); } return QWidget::event(ev); }};
C++ (Qt)if ((ev->type() == QEvent::MouseMove) || (ev->type() == QEvent::MouseButtonPress) || (ev->type() == QEvent::MouseButtonRelease) || (ev->type() == QEvent::MouseButtonDblClick) ){ ...}