Detect pen pressure of touch screen
-
I'm develping a palette app using canvas.
When drawing line on a touch screen(MS Surface notebook), I want to adjust lineWidth according the pen pressure(thicker or thinner).
How to achieve this?@rock-wang
that sounds like a very platform specific issue, doubtfull that theres a Qt-api for that, I may be wrong though.I would look to Microsoft and c++ accessable pen pressure
for example this Microsoft forum thread:
https://social.msdn.microsoft.com/Forums/vstudio/en-US/4fc58526-78c9-4955-a17d-c1dacd90b869/how-is-pressure-of-pen-acquired-in-c-?forum=tabletandtouch -
I don't have a Surface to test with, but in theory, it should use the same API's as stuff like Wacom tablets: http://doc.qt.io/qt-5/qtwidgets-widgets-tablet-example.html
QTabletEvent has a pressure() method that you can use to control line thickness of whatever is appropriate for your app. If the tablet example at that link doesn't respond to the Surface pen, then I don't know if there will be an easy way to use it with Qt API's. You might have to look into directly getting native events and mucking around with Windows specific event handling code, which is a bit gross.