As I write on title, I hope to show mouse position like tooltip. To do that, I think that I have to override QCursor, right?
But I don’t know the details of QCursor and how to make a new cursorShape.
Is there any example like this?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Assuming you want a coordinate readout as you move the cursor (like in many graphics or CAD applications), you really do not want to override
QCursor.The most efficient approach depends on what widget will be providing the coordinates, but in most cases the simplest way will be to
setMouseTracking(true)for the widget, and override it’smouseMoveEvent(QMouseEvent* event)to display aQToolTiplike so:Normally you would not ‘force’ a tooltip like this; you would use
QWidget::setToolTip(const QString&)or capture tooltip events inQWidget::event(QEvent*). But normalQToolTips only appear after short delay, but you want them updated continuously.I should state that I haven’t tried this, but this is the way I would do it. Hope that helps!