[Interest] Qt 5.6 and labs.controls for mobile development

Nurmi J-P jpnurmi at theqtcompany.com
Mon Feb 15 13:50:08 CET 2016


Hi,

> On 14 Feb 2016, at 19:56, ekke <ekke at ekkes-corner.org> wrote:
> 
> just before starting my blog articles about Qt 5.6 for mobile development have some questions:
> 
> Mobile Development for Android, iOS (later W10)
> What's the best way to develop for more then one platform from one Qt Creator Project ?
> read about QtFileSelectors and think they can help with .qml files and also images:
> placing them in +android, +ios folders I should be able to use different icon sets and do some fine-tuning in UI.
> For Android the Material styled controls are looking good.
> Using some iOS - specific icons will help to use Material for iOS apps.
> Am I right, that using file selectors this selection will happen at runtime ?

Yes, the selection happens at runtime.

> So always all kinds of resources will be deployed ?

Sharing and separating platform specific resources can be done by using platform scopes in the .pro file.

# resources that apply to all platforms
RESOURCES += myapp.qrc

# Android specific resources
android: RESOURCES += myapp_android.qrc

# iOS specific resources
ios: RESOURCES += myapp_ios.qrc

> And what about CPP code - what's the easiest way to manage different target platforms like Android and iOS ?

You could use the Q_OS_* macros (eg. Q_OS_ANDROID) for smaller platform specific code blocks. If you have more complex platform specific features, it’s usually better to have separate source files (eg. myfeature_android.cpp) and use the same technique than shown above for resources.

> Thanks for all tips and hints - don't want to publish wrong recipes ;-)
> 
> Using different styling (Material vs Universal)
> the Qt 5.6 qt.labs.controls Gallery example does the switch at startup using QT_LABS_CONTROLS_STYLE.
> This works for the qt.labs.controls
> But as soon as I'm customizing controls I have to...
> import Qt.labs.controls.material 1.0
> ....
> color: Material.accentColor
> ....
> so the customized controls have different code for Material and Universal
> HowTo deal with this ?
> Or should I restrict Universal to Windows ? Then I could use the FileSelectors.

We’re working on adding the style names as built-in selectors, so in the future you could have MyPage.qml, +material/MyPage and +universal/MyPage.qml if you want to do more complex style specific tweaks.

--
J-P Nurmi



More information about the Interest mailing list