0

I have some rectangle link area on my widget. What is the best way to make cursor Qt::PointingHandCursor when it is in this area?
enter image description here

Ufx
  • 2,595
  • 12
  • 44
  • 83
  • How are you handling the interaction on the link area without it being a child widget? – RobbieE Dec 24 '15 at 08:52
  • I draw text and handle click signal. My problem is no widget leaved signal so when I move cursor up it stays override cursor. Actually I want to make a link in the right part of menu bar. https://stackoverflow.com/questions/34433958/how-to-get-minimize-restore-close-rectangle – Ufx Dec 24 '15 at 08:59
  • may be you know how can I add a widget to solve my problem? – Ufx Dec 24 '15 at 10:35

1 Answers1

0

The QWidget class has a cursor property that you can set with the cursor you wish displayed when the mouse is above it.

EDIT: Without more detail on what you are trying to achieve, I can only assume you're making your life much more difficult than it needs to be. You can create a QLabel widget to handle the link and then place the label on the menubar automatically.

QLabel *link = new QLabel("<a href='http://doc.qt.io'>Qt Documentation</a>");
menuBar()->setCornerWidget(link);

All the text formatting, cursor display and user interactions are handled by existing code in the Qt classes. The only thing you need to do yourself is to handle what happens when the user clicks on the link, that you can do by connecting a slot to the QLabel::linkActivated(const QString &) signal.

RobbieE
  • 4,280
  • 3
  • 22
  • 36