Qt -- change the Mouse shape, Qt -- the Mouse shape
To change the shape of the mouse, it is useful when drawing the coordinate system. Please note:
1 this-> setMouseTracking (true); // set to trigger moveEvent 2 void mouseMoveEvent (QMouseEvent * event) 3 {4 QPoint mousepos = event () without pressing the mouse key () -> pos (); 5 6 // in coordinates (0 ~ Width, 0 ~ Height) changes the Mouse shape within the range of 7 if (mousepos. rx ()> 0 8 & mousepos. rx () <width 9 & mousepos. ry ()> 010 & mousepos. ry ()
Enumerated values corresponding to the Mouse shape:
Qt: ArrowCursor
Qt: UpArrowCursor
Qt: CrossCursor
Qt: IBeamCursor
Qt: WaitCursor
Qt: BusyCursor
Qt: ForbiddenCursor
Qt: PointingHandCursor
Qt: WhatsThisCursor
Qt: SizeVerCursor
Qt: SizeHorCursor
Qt: SizeBDiagCursor
Qt: SizeFDiagCursor
Qt: SizeAllCursor
Qt: SplitVCursor
Qt: SplitHCursor
Qt: OpenHandCursor
Qt: ClosedHandCursor
Qt: BlankCursor
You can also customize the Mouse shape:
1 Qcurosr * myCursor = new QCursor (QPixmap (":/images/custom.png"),-1,-1); //-1, -1 indicates that the hotspot is located in the image Center 2 this-> setCursor (* myCursor );