In this chapter you’ll discover why familiar desktop approaches fail on iOS/Android, and we’ll reveal how professional developers proactively build resilience to real mobile conditions: user movement, weak devices, memory constraints, and unstable networks. You’ll learn the secret of “mobile thinking” that saves weeks of debugging and significantly improves release quality.
We’ll cover key iOS project settings in Xcode (Minimum Deployment, Bundle Identifier, Version/Build), rotation handling via QScreen and Screen.orientation, as well as connecting QtSensors and working with Accelerometer. Plus—practical UI rules: how not to “drown” elements under fingers and why absolute positioning becomes a trap.
Don’t miss: one wrong orientation strategy choice—and you’ll rewrite the interface twice.
This chapter includes ready-to-use code examples.
Chapter Self-Assessment
Why should mobile apps focus on one main idea rather than include many features?Answer
Correct answer: Mobile device users are often on the move, their attention is scattered, and app usage time is measured in short intervals, so simplicity and focus on one idea are critically important for convenience.
What is a Bundle Identifier in an iOS app and why must it be unique?Answer
Correct answer: It’s a unique identifier in reverse domain name format (e.g., com.neonway.App) that the iOS system uses to distinguish apps; without uniqueness, conflicts will occur during installation and operation.
Why do apps that excessively consume battery usually get deleted after the first launch?Answer
Correct answer: Rapid battery drain is critical for mobile users, so such apps are perceived as unacceptable and receive negative reviews, making their lifespan on the device extremely short.
What’s the difference between Version and Build properties in iOS app settings?Answer
Correct answer: Version is the user-visible version number (e.g., 1.25) that increases with significant changes, while Build is an internal build identifier that increases with each new compilation even when Version remains unchanged.
Why is it not enough to simply resize interface elements when the device rotates?Answer
Correct answer: When orientation changes, the screen’s aspect ratio changes, which can lead to inefficient use of space, empty zones, and suboptimal content display; often you need to change the way elements are arranged or use different interface versions.
What happens if you set absolute positions for elements instead of using automatic layouts and anchors?Answer
Correct answer: The interface won’t be able to adapt correctly when screen orientation changes or on devices with different display sizes, leading to element overlap, content clipping, or unused screen areas.
Why is the skipDuplicates property set to true in the accelerometer example?Answer
Correct answer: This conserves battery by excluding processing of duplicate data that doesn’t provide new information about the device’s position.
Why can the accelerometer sensor serve as a joystick replacement in games?Answer
Correct answer: The accelerometer provides data about acceleration and tilt of the device in three-dimensional space, allowing you to control game objects naturally through physical device movements—for example, rotation for steering or tilt for acceleration.
What’s the fundamental difference between touchscreen interaction and working with a computer mouse?Answer
Correct answer: Users can touch the screen with multiple fingers simultaneously (multitouch), but there’s no right-click button and positioning accuracy is lower due to finger size.
Why is testing gestures on an emulator insufficient to verify app functionality?Answer
Correct answer: The emulator doesn’t convey real tactile sensations and physical characteristics of performing gestures with fingers, which are critical for evaluating comfort and naturalness of interaction.
What happens if an app tries to write data to a device without checking available storage space?Answer
Correct answer: A hardware failure or critical app error may occur, especially on older devices with limited memory, leading to data loss and a negative user experience.
Why is it better to place informational content in the upper half of the screen and controls in the lower half?Answer
Correct answer: When holding a smartphone in one hand or a tablet with two hands from below, the thumbs are at the bottom and can cover the lower part of the screen; placing information at the top ensures visibility, while controls at the bottom provide convenient access.
What is the axesOrientationMode property with FixedOrientation value used for in the accelerometer?Answer
Correct answer: This fixes the sensor axes direction so they remain unchanged even when the device screen rotates, ensuring predictable behavior when orientation changes.
Why is it necessary to ask user permission before downloading large amounts of data over the network?Answer
Correct answer: Mobile networks may have limited bandwidth and low throughput, and downloading large volumes can result in financial costs to the user and long waiting times, so it’s important to obtain consent.
When is it better to create separate apps instead of one with many features?Answer
Correct answer: If each function represents a separate independent idea requiring significant user attention; this simplifies usage, improves focus, and reduces cognitive load on the user.
Practical Assignments
Easy Level
Orientation Detector with Visualization
Create a Qt application that displays the current device orientation (portrait or landscape) and changes the background color depending on orientation: blue for portrait, green for landscape. Additionally, display the screen dimensions (width and height) as text.
Hints: Use the Screen element from the QtQuick.Window module. Bind the orientation property to a custom property. In the onOrientationChanged handler, check for Qt.LandscapeOrientation and Qt.PortraitOrientation values. Use Screen.width and Screen.height to display dimensions.
Medium Level
Compass with Visual Indication
Develop a mobile compass app that uses the magnetometer to determine the direction to north. Implement a visual representation with a rotating arrow pointing north and text display of the angle in degrees. Add an accuracy indicator and the ability to calibrate the sensor.
Hints: Import the QtSensors module and use the Magnetometer element. For visualization, create an arrow image (Rectangle with a rounded end) and use the rotation property for rotation. Get the angle value from reading.azimuth. Set dataRate to 50-100 for smoothness. Add an active property dependent on app state.
Hard Level
Adaptive Image Gallery
Create a gallery app that automatically changes the image display method when the device rotates: in portrait orientation, it shows a vertical list with thumbnails (ListView), and in landscape—a horizontal coverflow-style carousel with enlarged images. Implement gesture support: Pinch for zooming individual images, Swipe for navigation, DoubleTap to switch to fullscreen mode. Add a current position indicator and total image count.
Hints: Use two different views (ListView and PathView) and toggle their visibility based on Screen.orientation. For gestures, apply PinchArea, MouseArea with propagateComposedEvents property, and DoubleClicked. Store the image list in a ListModel. Use Behavior on properties for smooth transitions. Optimize memory consumption through Image.asynchronous and sourceSize. Don’t forget to handle edge cases during scaling.
💬 Join the Discussion!
Got a handle on mobile development specifics? Questions about working with sensors or optimizing battery consumption?
Share your experience adapting apps for different screen orientations, discuss best practices for working with gestures, or help other readers master QtSensors!
Your experience could be a valuable find for the Qt mobile app developer community!