Replacing GetAsyncKeyState in painting code
Unsolved
General and Desktop
-
I'm converting some Windows code that has the following in the repainting code:
bool forceHere = (GetAsyncKeyState(VK_SHIFT) & 0x8000);
The intention is that if the shift key is pressed at this time, then things are drawn a little differently.
I think that I can remove the call to GetAsyncKeyState(), and change forceHere from being a local variable to be a member variable, I could then write a MouseMove handler like this:
void ClassName::mouseMoveEvent(QMouseEvent* e) { if (e->modifiers() & Qt::ShiftModifier) forceHere = true; else forceHere = false; update(); }
which I think would have the same end result. Is that correct?
Thanks
David -
You can also check the modifier state during your paintEvent.
-
@Perdrix said in Replacing GetAsyncKeyState in painting code:
error C2039: 'modifiers': is not a member of 'QPaintEvent'
And that's correct. It's a function of QGuiApplication as properly documented.