path: root/src/plugins/platforms/ios/
diff options
authorTor Arne Vestbø <>2015-10-19 14:11:28 +0200
committerTor Arne Vestbø <>2015-11-26 02:45:57 +0000
commit980f8aed32403527e2922c2c671bbe29a6911c70 (patch)
treeb8069e58d479374056598224ba5d256bfe576fab /src/plugins/platforms/ios/
parent9b28fd5bfcedef16e2f4c59124f0628670f96556 (diff)
iOS: Add support for delivering touch pressure on iPhone 6s/6s+ devices
As 3D touch can be disabled/enabled at runtime on those devices, we need to watch for changes to the relevant settings and update the touch device capabilities that we report to the user. Note that iOS will deliver touchesBegan with a touch force of 0, which we will reflect/propagate as a 0 pressure, but there is no clear alternative, as we don't want to wait for a touchedMoved before sending a touch press event to Qt, just to have a valid pressure. Change-Id: I47fb8a9f98ab3244e16a337bbfcf1fe24e4c7aa2 Reviewed-by: Tor Arne Vestbø <>
Diffstat (limited to 'src/plugins/platforms/ios/')
1 files changed, 7 insertions, 3 deletions
diff --git a/src/plugins/platforms/ios/ b/src/plugins/platforms/ios/
index eaff0daf19..0e3da8dce8 100644
--- a/src/plugins/platforms/ios/
+++ b/src/plugins/platforms/ios/
@@ -89,10 +89,11 @@ QIOSIntegration::QIOSIntegration()
// Set current directory to app bundle folder
QDir::setCurrent(QString::fromUtf8([[[NSBundle mainBundle] bundlePath] UTF8String]));
+ UIScreen *mainScreen = [UIScreen mainScreen];
NSMutableArray *screens = [[[UIScreen screens] mutableCopy] autorelease];
- if (![screens containsObject:[UIScreen mainScreen]]) {
+ if (![screens containsObject:mainScreen]) {
// Fallback for iOS 7.1 (QTBUG-42345)
- [screens insertObject:[UIScreen mainScreen] atIndex:0];
+ [screens insertObject:mainScreen atIndex:0];
for (UIScreen *screen in screens)
@@ -103,7 +104,10 @@ QIOSIntegration::QIOSIntegration()
m_touchDevice = new QTouchDevice;
- m_touchDevice->setCapabilities(QTouchDevice::Position | QTouchDevice::NormalizedPosition);
+ QTouchDevice::Capabilities touchCapabilities = QTouchDevice::Position | QTouchDevice::NormalizedPosition;
+ if (mainScreen.traitCollection.forceTouchCapability == UIForceTouchCapabilityAvailable)
+ touchCapabilities |= QTouchDevice::Pressure;
+ m_touchDevice->setCapabilities(touchCapabilities);