Now Reading
Utilizing Qt for Cellular in 2023 | Cameron Gaertner

Utilizing Qt for Cellular in 2023 | Cameron Gaertner

2023-12-25 17:38:55

Having used Qt for the previous few years in a cross-platform app, I’ve come throughout an increasing number of points that preserve piling up on cellular, to the purpose I’m starting to assume that Qt just isn’t the only option in 2023. Whereas Qt continues to be fairly good for desktop improvement, there are a number of areas it’s missing in cellular dev.

The aim of this submit is to spotlight these areas for each builders evaluating Qt, and for The Qt Firm to know developer ache factors.

The two paths of mobile development

Contact Interplay / UI Efficiency

Qt handles all rendering of the UI in its personal stack, and doesn’t use native parts like another cross-platform frameworks (i.e React Native). This results in contact interplay feeling noticeably worse than a local or React Native app. For instance, the ListView in QML, Qt’s UI markup language, doesn’t assist inertial scrolling.

Qt’s ListView

React Native’s ListView

Within the above movies, discover how the short scrolls in Qt’s ListView barely transfer the view. In React Native, these huge and fast swipes transfer the view significantly, and have an inertia that feels good.

The shortage of inertial scrolling comes up in different parts, just like the SwipeView and Drawer. QML does present a extra generic MouseArea that you might use to attempt to design this your self, however sadly the result’s unlikely to be performant sufficient to make use of, as a consequence of every thing going by way of Qt’s customized contact stack. The customized contact stack additionally makes buttons and different interactions really feel laggy.

Filesystem

On desktop, Qt’s file APIs work fairly effectively. On Android or iOS, they’re extra bother than they’re value. With Android’s Scoped storage updates in Android 11, an app can’t entry consumer information with out opening a local dialog for them to pick out them. As soon as the consumer selects them, an app will get a content material URI that it may learn by way of. Qt’s filesystem APIs don’t account for any of this. This may be seen in Qt’s File System Explorer instance which is at present damaged.

Qt’s file browser (does not load any information)

As a workaround, KDAB has launched a sharedstorage library that works properly.

On iOS, you may attempt the FileDialog QML sort, but it surely doesn’t work for images, even if you happen to specify i.e folder: StandardPaths: PicturesLocation.

Textual content Interplay

Keyboard Points

In case your app makes use of any textual content enter, you’ll most likely have to put in writing plenty of code to open and shut the keyboard correctly and work round different Qt bugs. There are additionally many points coping with autocorrect and predictive textual content on sure keyboards, i.e Gboard on Android (QTBUG-120238). On iOS, the keyboard typically stays open and can’t be closed with Qt’s Qt.inputMethod.conceal() technique (QTBUG-119601).

Sadly, there are a lot of different related points, a few of which have been open for years, and as Android and iOS get software program updates, you may all the time discover keyboard interplay to be damaged ultimately.

Textual content Handles, Copy/Paste/Choose

These should be carried out your self. That is harder than it appears, because of the many edge instances, and the issue in getting it to really feel clean or native. In truth, that is at present damaged in Qt’s texteditor example.

Qt’s texteditor instance, with some unusual window glitching when making an attempt to pick out textual content

Permissions

Qt is at present engaged on its Permissions API, however it’s nonetheless a piece in progress and solely accommodates assist for six permissions on Android.

See Also

This module was fully rewritten in Qt 6. Sadly, Blueooth enter doesn’t work on Android or iOS. On Android, I used to be unable to get any Bluetooth enter utilizing Qt’s audiosource example. On iOS, the Bluetooth gadget just isn’t even acknowledged.

Developer Expertise

It has gotten higher previously couple of years, however the developer expertise of Qt on cellular continues to be missing in my view. When utilizing Qt, it’s advisable to make use of Qt Creator for improvement/deployment. Nevertheless, Qt Creator’s Android debugging is flakey at finest, and iOS debugging by way of Qt Creator is at present non-existent for iOS 17 units (iOS 17 was launched ~3 months in the past at time of writing).

Other than debugging, there’s an terrible lot of discovery work wanted to attain habits that’s included by default in native apps, main one to query if it’s all actually value it. The Qt neighborhood can be small in comparison with i.e React Native, so there could also be no solutions on-line on the way to do X with Qt.

Conclusion

I believe that Qt wants to speculate extra in its cellular APIs and efficiency. Whereas the framework could match sure use instances, the efficiency of the UI (contact interactions, textual content interactions, loading, and many others) make it not possible to make an app with nice UX. The shortage of cellular APIs might be troublesome, however native integration is all the time essential to some extent.

Alternatively, Qt could make sense for some groups which have already got a big Qt codebase on desktop. Whereas a separate cellular UI could be wanted, with the ability to reuse giant parts of present code might outweigh the UX points talked about above. In any case, I stay up for seeing how Qt evolves, and proceed to get pleasure from utilizing it on desktop.

Different choices?

With the ability to share UI and code on Android and iOS continues to be a want for a lot of builders. As hinted all through the submit, I believe React Native could be the solely different doable contender. Flutter might also be an possibility, however I’m skeptical of their option to deal with all rendering and contact interplay themselves.

Like React Native, Flutter makes use of reactive-style views. Nevertheless, whereas RN transpiles to native widgets, Flutter compiles all the best way to native code. Flutter controls every pixel on the display screen, which avoids efficiency issues attributable to the necessity for a JavaScript bridge.

Flutter for React Native developers

I haven’t had time to attempt RN or Flutter in a severe means but, however I’m trying ahead to doing so sooner or later.

Source Link

What's Your Reaction?
Excited
0
Happy
0
In Love
0
Not Sure
0
Silly
0
View Comments (0)

Leave a Reply

Your email address will not be published.

2022 Blinking Robots.
WordPress by Doejo

Scroll To Top