Important: Please read the Qt Code of Conduct -

Testing the mouse cursor shape

  • Making an automatic test for my widget, I want to check whether the mouse cursor will correctly change its shape when the mouse moves over a particular zone. Typically my test would look like:

    MySpecialWidget w;;
    QTest::mouseMove(&w, w.centerPointOfTheSpecialZone());
    QCursor c = ?; // finding out the current cursor here!
    Qt::CursorShape expectedShape = ?; // it's not the point here
    QCOMPARE(c.shape(), expectedShape);

    How could I test it?

  • Hi and welcome to devnet,

    reading from docs QWidget::cursor() should do the job. Have you tried it?

Log in to reply