0

How can I get cursor shape when application minimized?

on hotkey I call:

qDebug() << "mouse (" << QCursor::pos().x() <<  "x" << QCursor::pos().y() << ")" << this->cursor().shape();

QCursor::pos() - is right, but cursor().shape() - always return "ArrowCursor" (even within the application).

How can I get real shape or cursor pixmap (Windows, MacOS)?

user1706674
  • 49
  • 1
  • 7
  • Why in the world are you interested in such a thing? – peppe Jul 01 '16 at 20:22
  • From Qt Assistant: "`QCursor::pixmap() const` Returns the cursor pixmap. This is only valid if the cursor is a pixmap cursor." Is it? – ilotXXI Jul 01 '16 at 20:30
  • @peppe When you want a non-standard cursor based on a standard one (e.g. coloured). Or when you need a non-standard behaviour that should show a standard familiar cursor. – ilotXXI Jul 01 '16 at 20:33
  • @ilotXXI: that doesn't sound at all about what OP is asking. OP is asking about getting the cursor shape when the cursor is currently in another application or similar, which is a very strange use case to me. – peppe Jul 01 '16 at 21:08
  • @peppe I capture screenshot and need to impose cursor on him over. – user1706674 Jul 01 '16 at 21:17
  • Ok, in which case I'm afraid you'll need to use platform specific code. There's no way in Qt. (However those platform specific ways should be well documented...) – peppe Jul 02 '16 at 08:20
  • @peppe mey be you have some link how to do that in win and osx? – user1706674 Jul 04 '16 at 09:05
  • https://stackoverflow.com/questions/3291167/how-to-make-screen-screenshot-with-win32-in-c plus calls into [GetCursorInfo](https://msdn.microsoft.com/en-us/library/windows/desktop/ms648389(v=vs.85).aspx) and DrawIcon to draw it. – peppe Jul 04 '16 at 09:35

1 Answers1

1

I don't think you can do this, at least not with Qt.

this->cursor() gives you a QCursor that was set on a certain QWidget using QWidget::setCursor. It's a simple accessor. It does not give you the current cursor being displayed (outside your program, window, not even outside the widget).

LogicStuff
  • 18,687
  • 6
  • 49
  • 70