Archives For Qt for Mobile

Qt mobile APP development (Android, iOS, Windows 10)

Qt 5.8 brings some more support of Text Selection Handles, but there are still also some problems. Text Selection Handles are important to make it easy on touch devices to insert text, copy text, replace text or cut text. With 5.7 single taps to get a handle to move the insert position around already works.

Select words by double tap

Qt 5.8 also supports double tap to select words – but it doesn’t work as expected. This selection mode will only be enabled if you set

selectByMouse: true

on TextField or TextArea. This works fine with TextFields, but having TextArea inside Flickable makes scrolling difficult or impossible. Qt doesn’t know if you want to change the selection or scroll inside the TextField or scroll the Page. Users will be confused and it’s not easy to know where outside the Textfield scrolling works. Hopefully in Qt 5.9 this will befixed and double tap works without setting ‘selectByMouse’.

One of my app contains many TextAreas and users are waiting for word-selection-mode, so I developed some workarounds for 5.8.

To make it easier to distinguish where’s the TextArea I placed the TextArea on top of a Pane. Now you can tell your user to scroll the Page place fingers outside the TextArea:

As soon as TextArea gets active focus, 3 buttons will appear on the right side:

  • clear
  • toggle selection mode
  • done

As soon as the user does a double-tap on a word both text selection handlers become visible and it’s easy to move them around to select more or less.

Also please notice on top a menu to select all, cut, copy and paste.

On iOS this is different: at first do the double tap to select a word – then please do a long press on the selection to get a cut, copy, paste, delete menu just on top of the selection:

Single tap does work with or without setting ‘selectByMouse’:

To insert from clipboard do a long-press: ‘insert’ menu appears on top of cursor position.

Tap on the Toggle Button to set selectByMouse = false to make it easier to scroll also while inside the Textfield.

When you’re ready with text editing tap on the ‘Done’ Button. Done Button gets focus and all Handles disappear. Also Done and Toggle Button disappear.

As long as there’s some text, the clear Button makes it easy to clear the field:

Here’s the workaround. I placed all of this into ‘TextAreaRow.qml’ – then it will be easy to change when 5.9 comes out.

TextAreaRow{
    id: remarksTextRow
    placeholderText: qsTr("Your Remarks (RETURN for new line)")
    text: tourDetail.remark
    onTextChanged: {
        tourDetail.remark = text
    }
    onDone: {
        // do something: set active focus to another field or so
    }
} // remarksTextRow

And here’s the implementation:

RowLayout {
    id: theTextRow
    signal done()
    property alias text: theTextField.text
    property alias placeholderText: theTextField.placeholderText
    property alias textField: theTextField
    property int minHeightTextPane: 140
    property bool doubleTapIsDefault: true
    Pane {
        id: textPane
        anchors.top: parent.top
        Material.elevation: 6
        Layout.fillWidth: true
        Layout.minimumHeight: theTextField.activeFocus? minHeightTextPane : 60
        TextArea {
            id: theTextField
            // Qt 5.8
            // only if set to true we can mark words by double tap
            selectByMouse: doubleTapIsDefault
            // important - otherwise text goes endless without wrapping
            width: parent.width
            text: ""
            wrapMode: TextArea.WordWrap
        } // theTextField
    } // text pane
    Column {
        spacing: 0
        anchors.top: textPane.top
        Layout.minimumWidth: textClearButton.visible || textSelectToggleButton.visible || textDoneButton.visible? 48 : 0
        ButtonIconActive {
            id: textClearButton
            anchors.horizontalCenter: parent.horizontalCenter
            visible: theTextField.activeFocus || theTextField.text.length
            focusPolicy: Qt.ClickFocus
            imageName: "clear.png"
            onClicked: {
                theTextField.text = ""
            }
        } // textClearButton
        ButtonIconActive {
            id: textSelectToggleButton
            anchors.horizontalCenter: parent.horizontalCenter
            visible: theTextField.activeFocus
            focusPolicy: Qt.ClickFocus
            imageName: "code.png"
            onClicked: {
                theTextField.selectByMouse = !theTextField.selectByMouse
                if(theTextField.selectByMouse) {
                    appWindow.showToast(qsTr("Word Selection by Double Tap switched ON"))
                } else {
                    appWindow.showToast(qsTr("Word Selection by Double Tap switched OFF"))
                }
            }
        } // textSelectButton
        ButtonIconActive {
            id: textDoneButton
            anchors.horizontalCenter: parent.horizontalCenter
            visible: theTextField.activeFocus
            focusPolicy: Qt.ClickFocus
            imageName: "done.png"
            onClicked: {
                // we only need the focus
                // emit signal so users can give another field the activeFocus
                theTextRow.done()
            }
        } // textDoneButton
    }
} // row w text area

ButtonIconActive is a customized Button showing Icon. You’ll find all of this in my sample apps at Github – I also have updated QtWorldSummit Conference App.

On Android there are two bugs:

Selection handles overlap while scrolling (Android only)

The selection handle(s) can overlap the keyboard or selection menu:

Take a look at BUG 58700

Selection Handle visible when Component invisible

If the Component containing your TextField or TextArea becomes invisible and the TextField still has active focus, the handles will still be visible.

See BUG 58700

Workaround is easy: set focus to another field as soon as TextField becomes invisible.


← Back (Update 5.7 to 5.8)

→ Next Article (Qt Creator – Intro)

⇐ Home (Overview / Topics)


Before debugging and running a work APP on your managed Android device from Qt Creator

  • your device must be activated as Android for Work device
  • your must have sent a release build to your Admin and this APP must be published to Google Play for Work
  • you must have installed the work APP on your managed device

Deploy to Device

Build and deploy your APP as usual from Qt Creator to your (managed) Android device.

If all works well, the APP (named PegelMeter) will appear twice on your device.

This is expected behavior – read more here – topic “Testing on managed profiles – tips and tricks“.

Run the work APP

Unfortunately you’ll notice that Qt Creator runs the private version of the APP and not the work version.

This is because Qt Creator doesn’t know that we want to run a work app. Private and Work apps are bound to the user.

Work User vs Private User (managed Android Device)

Default user is user 0, where the work user normally is user 10. You can list your users from Terminal:

adb shell pm list users

you’ll get something like this:

Users:
    UserInfo{0:1799924875:13} running
    UserInfo{10:141078676:30} running

User 0 –> default (private) user

User 10 –> work user

Run as Work App

You can run the APP from Terminal as Work APP:

adb shell am start --user 10 -n org.ekkescorner.xxx.pegelmeter.dev/org.qtproject.qt5.android.bindings.QtActivity

QtCreator starts the APP without –user which always will use the default one (0)

I’ll open a bug report and request to add a Variable USER_ID so this can be placed inside .pro and added to adb start command by Qt build process.

Starting the work APP from Terminal you’re loosing the log output inside QT Creator. Workaround could be to log from adb or to use an extra tool.

This will give you the logs using adb:

adb -d logcat libpegelMeter_x.so:D *:S

A special tool gives you some more comfort filtering the logs. For OSX I can recommend LogRabbit. It’s easy to filter out the logs from your APP.

External Tool

As we have seen, Build and Run the APP starts the private APP.  So you have to stop and close the private APP and then start the work APP from Terminal.

To make this easier I added this to External Tools in Qt Creator:

I checked Output: Show in Pane – but nothing is printed. Probably I forgot something to tell External Tools that APP output should be visible in Application Output Pane. As long as this doesn’t work I’m using LogRabbit (see above)

External Tools ‘start_pegelmeter_work.sh’ executes this script:

#!/bin/sh
cd <path-to->/platform-tools
./adb shell pm clear --user 0 org.ekkescorner.xxx.pegelmeter.dev
./adb shell am start --user 10 -n org.ekkescorner.xxx.pegelmeter.dev/org.qtproject.qt5.android.bindings.QtActivity

Now it’s easier:

  • Build and Run APP
  • ExternalTools – Kill running private APP and Start Work APP

I would like to use a variable for User Id and also for APP Name and APP Package. (see QTCREATORBUG-17863)

and here’s the request to add USER_ID to be placed inside .pro: QTCREATORBUG-17862


← Back (Deploy Android Work App to Google Play)

→ Next Article (…work in progress…)

⇐ Home (Overview / Topics)


Publish to Google Play Store for Work

Your BlackBerry UEM Admin must publish your APP to Google Play Store for Work.

The APP must not be uploaded to Google Play but will be registered.

The workflow is similar to publishing a ‘normal’ APP to Google Play, so you need screenshots, artwork, description, …

Here’s a guide what the Admin has to do:

This guide is from 2016 – but the workflow still is the same. All described for BES12 will work using UEM 12.6

As soon as Google has approved the APP the Admin can configure on which devices / users / user-groups the APP should be installed.

Developer Policies

The Admin typically will create Policy profiles matching the rights a user-group should have for work APPs.

Attention: To be able to deploy debug builds from QtCreator to your device the Admin must add these extra policies to developers:

  • Apps
    • Allow installation of non Google Play apps
    • Allow developer options

If you cannot deploy and run work apps from QtCreator ask your Admin if these policies are set for your device.


← Back (Activate Android Device for Work)

→ Next Article (Debug and Run managed Qt Android App | QtCreator)

⇐ Home (Overview / Topics)


There are different ways to activate a Device:

  • Managed Accounts
  • Google Domains

My example and sceenshots are based on ‘Managed Accounts’, which is the easiest way. If you’re using Google Domains then it’s much more complex and for each User you need a dedicated Work Google Play Account. The newest BlackBerry UEM 12.6 supports ‘Managed Accounts’.

To activate a Android device for work (‘Managed Account’), you’ll receive an eMail from the Admin (email address, password)

BlackBerry UEM Client

Please download the BlackBerry UEM Client APP from Google Play

Open the UEM Client and enter email address and password.

Configure your profile.

Device will be activated:

Play Store for Work

Automatically some work apps will be added. Here you see the Play Store for Work (left) and the usual private Play Store:

Please open the Play Store for Work. If you don’t have used a Google Mail address (different from your personal Goofle Mail address) for activation, it can happen that you get an error:

try to switch off / on the airplane-mode or restart the device to see your work apps.

Your Work APPs

in this case there’s one app available – the app you sent to the admin:

Two APPs (Work, Private)

Install the APP as usual and you’ll get 2 APPs: one as private, one as work app:

we only need this app as work APP, so you can delete the private one.

Now as your APP exists as a work APP you can deploy updates from Qt Creator and use the work profile.

Android for Work Statusbar

Open your work APP and take a look at Android statusbar:

you’ll always see if the current APP is a work app and you’ll also see if currently there’s a secure connection to server (VPN)

Secure Connection

All your Work APPs will use the secure connection. There’s also a second Browser: Chrome for Work. Opening sites from Chrome for Work or accessing URLs from your Work APP always goes thru the secure connection – this means those URLs will be opened behind the firewall same way as if you’re sitting in your office using the Intranet. Data used by Work APPs is encrypted and secure out of the box on transport and also on your device.

Secure Boot

Using BlackBerry Android Devices there’s some extra security built into the hardware. Those devices cannot be rooted.

Read more here and here.

BlackBerry and Android Devices ? You have read that there will be no more Devices built by BlackBerry ?

Yes – BlackBerry finished transition from hardware to software. BlackBerry licensed Devices to partners, but verifies security. First new device was presented by TCL at Mobile World Congress in Barcelona: keyONE with Android Nougat 7.1 – three more new devices will follow. BlackBerry Android Devices always get the monthly security updates for Android – per ex. Security Patches from march 2017.

It’s up to you or your customers how many levels of security they need. Android for Work is the first step, using devices with secure boot the next one.

Samsung does something similar with Samsung KNOX and Samsung devices, but fails with monthly security updates.


← Back (Overview managed Android Devices)

→ Next Article (Deploy Android Work App to Google Play)

⇐ Home (Overview / Topics)


If you’re developing mobile business apps sooner or later customers will request to debug, build and run on managed devices. This blog post is focused on Google for Work | Android (aka Android for Work).

Google for Work | Android

There are different ways to run work applications: devices may only contain work apps or private and work apps are installed together. From my experiences in most cases there are private and work apps together on devices. Read more about EMM (Enterprise Mobile Management) and different scenarios here.

There are some EMM solution providers:

  • BlackBerry
  • Mobileiron
  • VMware AirWatch

BlackBerry UEM 12.6

My examples are based on BlackBerry UEM 12.6 (formely known as BES 12)

You can try out UEM for 30 days (Cloud version) or 60 days (on-premises) for free.

Using a managed device is like working behind the firewall via VPN, but all is transparently managed by the EMM solution provider.

EMM Admin manages users, user groups, devices, policies and apps. Here you can download the policies for BlackBerry UEM. Get an overview of BlackBerry UEM here.

Development Stages (Dev, Test, Production)

Developing a new app there are typically 3 stages:

  1. develop UI with MockUp data (no access to servers needed)
  2. test against test environment
  3. release for production environment

Stage 1 I’m using GooglePlay Closed Beta Test to deploy the apps to beta testers from customer. Adding testers only gMail address is needed.

For stages 2 and 3 your device must be activated as Android for Work device or you should request a device to test on from your customer. This is the only way to get access to data servers behind the firewall – in most cases there will be no URL you can use from outside. One device can only be activated as work device for one server (BlackBerry UEM).

It’s highly recommended to test your APP as Work APP – the admin can forbid features (Bluetooth, NFC, Camera, …)

To manage apps your customer has to use a Google developer account to be able to publish apps through Google Play for Work.

Multi Android Package Names in Manifest

Attention: you must change the Android package name to enable your customer publishing the app to Google Play for work because the package name from stage 1 is already connected to your own Google developer account from Beta testing.

Also your Enterprise Customers can have different environemts for dev, test, production with different Google Developer Accounts to get a specific Play Store for Work for each environment. This means you must build releases for up to three or more different package names. Changing the package name manually in Android Manifest is not so comfortable. You can have a dynamic way following this blog article.

Best would be Qt Creator supports this directly using variables in .pro. see QTCREATORBUG-17863

Develop – Test – Release Workflow for Work APPs

Here’s an example workflow:

  • add your APP to Google Play Closed Beta Test (Android package name: my.example.beta)
  • deploy updates to beta testers until stage 1 finished
  • build release (Android package name: my.example.test) and send APK to your customer
  • your customer publishes APP to GooglePlay for Work
  • your customer creates user and profile for you and adds the APP to your user or user group
  • your customer sends an email to activate a device
  • you activate your device and install the APP from Google Play for Work on your device
  • now you can develop, build and run your APP from Qt Creator
  • build update releases and send to your customer
  • your customer publishes update to Google Play for Work so others can test your update

Hint: you can only build and run your app as work app if customer has published your app once to Google Play for Work and you installed it once !

Following pages will explain the steps in more detail:


← Back (EclipseCON Europe)

→ Next Article (Activate Android Device for Work)

⇐ Home (Overview / Topics)


you should already have installed the patch for QTBUG-59026 (RadioButtons Type) if you’re developing Android Apps.

While updating my projects from Qt 5.7 to 5.8 I was running into another show-stopper-bug:

Using the Drawer or Bottom Navigation Bar some color from pressing the buttons down remains after fingers are released. This happens on Android and iOS and the amount of color is different from case to case – sometimes not easy to detect.

Here are some screenshots so you can verify if this happens also in your apps:

drawer_presses

drawer_itemdelegate

Running example Apps like QtQuickControls2 Gallery all works well.

It took me some time to have a small reproducable test case and I opened QTBUG-59293

Again @jpnurmi could help and provides a patch.

Material: force ripple background when hidden

force_reset_ripple_bg

Now it’s easy to patch.

Hint: this time we must do this for the Android kit and also for the iOS kit.

Open a Terminal and do this to patch your Android Kit.

Attention: I’m using the Android repo I already cloned for the first patch.

export ANDROID_NDK_ROOT=/your_path_to/android-ndk-r10e
cd /your-path-to-store-cloned-repo_android
cd qtquickcontrols2
git fetch https://codereview.qt-project.org/qt/qtquickcontrols2 refs/changes/64/187564/1 && git cherry-pick FETCH_HEAD
/your-path-where-qt-is-installed/5.8/android_armv7/bin/qmake
make
make install

Now we’re doing the same for iOS. Create a folder where you want to store the repo. Then:

cd /your-path-to-store-cloned-repo_ios
git clone --branch 5.8 git://code.qt.io/qt/qtquickcontrols2.git
cd qtquickcontrols2
git fetch https://codereview.qt-project.org/qt/qtquickcontrols2 refs/changes/64/187564/1 && git cherry-pick FETCH_HEAD
/your-path-where-qt-is-installed/5.8/ios/bin/qmake
make
make install

Hint: ‘make’ can take some time

There are some other ways you only have one repo for Android and iOS – see comments from @jpnurmi at QTBUG-59293.

Now the Ripple Effect is working again inside a Drawer with Qt 5.8 and QtQuickControls2 🙂

One use-case is left where some color remains, but there’s a workaround, so I can go on moving my projects from 5.7 to 5.8

 

thanks @jpnurmi helping me to make this work.


← Back (Patch Qt 5.8 (BUG 59026))

→ Next Article (Update 5.7-5.8 – mostly harmless)

⇐ Home (Overview / Topics)


Update 2017-03-24: Added info about problems with Popups and Android BACK key

Update 2017-03-13: updated my openssl – repo to fix crash with QNAM

Update 2017-03-09: Added info Adding OpenSSL, added reference to comment from Tobias Hunger on ‘…choose a mkspec…’

Update 2017-03-07: Added a) very first iOS build signing issues and b) iOS Build Issues (patch bitcode.prf)

Update 2017-03-06: Critical QTBUG-59293 fixed – see patch

I’m not using the Maintenance Tool – I’m always installing a new Qt Release at a different location and also start Qt Creator with -settingsPath as blogged here

Then it’s easier to work with old and new release side-by-side and compare.

Update QML Imports

From a technical point you can use the ‘old’ imports. I’m always doing search/replace to update the imports. Then I’m sure all my QML files are accessing the newest Controls and Properties. Updating from  5.7 to 5.8 I replaced

import QtQuick 2.6
import QtQuick.Controls 2.0
import QtQuick.Controls.Material 2.0

with

import QtQuick 2.7
import QtQuick.Controls 2.1
import QtQuick.Controls.Material 2.1

Using a source control system like Git it’s a good idea to do this in an extra Branch – then it’s easier to go back if something went wrong.

First Test with Demo and Conference Apps

While writing this blog series on Qt for Mobile I developed some Demo Apps, where each Demo App has a specific Focus. This makes it easy to do the tests step-by-step.

I’m replacing the Imports, then compile and run the App on Android and iOS devices and take a look at Compile- and Application Output and Issues and go through the apps to see if all works as before.

My Demo Apps:

As next I’m testing my Conference Apps. These Apps are something more complex and I also test building release and upload to Google Play Beta Test and Apple TestFlight to see if Release also is working.

The good thing with the Demo and Qt Conference Apps: I published them Open Source to Github. So it’s easy for others to see what I changed or to verify problems.

When all my Demo and Conference Apps are working well, then the next step will be to do the same with my private customer repos.

Finally I can test and add new Controls / Features from QtQuickControls2 as J-P Nurmi blogged about here.

Let’s see what happened while doing the Update.

Mostly Harmless

I got many Warnings and Errors, but don’t panic, they’re mostly harmless.

Some Errors / Warnings / Issues are new – some exist a longer time. I’m listing them also here for devs new to ‘Qt for Mobile’

Very first build for iOS – signing issue

I moved my projects into a new 580 working dir and running the very first time an iOS Build (Debug or Release – doesn’t matter) the code compiles and then logs an error:

Provisioning profile "iOS Team Provisioning Profile: org.ekkescorner.xyz" doesn't include signing certificate "iPhone Developer: Ekkehard Gentz (4A4....VV3)".
Code signing is required for product type 'Application' in SDK 'iOS 10.2'
** BUILD FAILED **

Opening the generated Xcode project and then doing the build again all is working as expected. Even deleting the build dir and building again it works.

This is caused by Xcode automatic provisioning and out of scope from Qt. (see QTBUG-59350)

So don’t panic if the iOS build fails – simply open the Xcode project one time.

QML import could not be resolved

Building Android Apps you’ll see some warnings like

Warning: QML import could not be resolved in any of the import paths: org.ekkescorner.data
Warning: QML import could not be resolved in any of the import paths: QtQuick.Controls.impl
Warning: QML import could not be resolved in any of the import paths: QtQuick.Controls.Material.impl
Warning: QML import could not be resolved in any of the import paths: QtQuick.Controls.Universal.impl

There’s nothing wrong with this. Here’s an old Bug: QTBUG-47389

You can ignore this. Hopefully one day this will be fixed.

QQmlComponent: Component is not ready

While configuring my projects for Android, OSX, iOS I found under General Messages:

QML module does not contain information about components contained in plugins.

Module path: /daten/_qt_sdks/sdk_580/5.8/android_armv7/qml/QtGraphicalEffects
See "Using QML Modules with Plugins" in the documentation.

Automatic type dump of QML module failed.
Errors:
"/daten/_qt_sdks/sdk_580/5.8/clang_64/bin/qmlplugindump" returned exit code 3.
Arguments: -nonrelocatable QtGraphicalEffects 1.0 .
Error parsing dependencies file <outputOfQmlimportscanner>:illegal value at 0
failed to proecess output of qmlimportscanner
QQmlComponent: Component is not ready
file:///daten/_qt_sdks/sdk_580/5.8/android_armv7/qml/typelist.qml:2:1: plugin cannot be loaded for module "QtGraphicalEffects": '/daten/_qt_sdks/sdk_580/5.8/android_armv7/qml/QtGraphicalEffects/libqtgraphicaleffectsplugin.so' is not a valid Mach-O binary (invalid magic 7f454c46)

same happens with “QtQuick.Controls.Styles.Android”. From J-P Nurmi I got confirmation that I can ignore this.

For the first one on “QtGraphicalEffects” I wrote a Bug Report: QTCREATORBUG-17819.

You can ignore these errors.

Qt Quick Controls 2 ‘Binding Loops’

Some of my Apps are reporting Binding Loops.

On Android:

W libtab_pages_x.so: file:///data/data/org.qtproject.example.tab_pages_x/qt-reserved-files/qml/QtQuick/Controls.2/Material/TabBar.qml:52 ((null)): file:///data/data/org.qtproject.example.tab_pages_x/qt-reserved-files/qml/QtQuick/Controls.2/Material/TabBar.qml:52:18: QML ListView: Binding loop detected for property "implicitWidth"

On iOS:

qrc:/qt-project.org/imports/QtQuick/Controls.2/Material/TabBar.qml:52:18: QML ListView: Binding loop detected for property "implicitWidth"

same happens for “preferredHighlightEnd”.

Unfortunately I wasn’t able to create a small test scenario yet, but will try again and open an Issue later.

Most important: You can ignore this Warning.

Please update your kit or choose a mkspec for qmake

Configuring a project for iOS I got

"/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang++" is used by qmake, but "/usr/bin/clang++" is configured in the kit.
Please update your kit or choose a mkspec for qmake that matches your target environment better.

issue_01

I created a bugreport: QTCREATORBUG-17794

From qt-creator List I got confirmation: This message is wrong and you can ignore this.

see here a comment from Tobias Hunger why this happens.

-headerpad_max_install_names is ignored

Building project for iOS I got this Issue:

:-1: warning: -headerpad_max_install_names is ignored when used with -bitcode_bundle (Xcode setting ENABLE_BITCODE=YES)

issue_02

From qt-creator List I got confirmation that this can be ignored. See also codereview 185929

codereview_headerpad

so next Qt releases will have this fixed.

member of multiple groups (“Supporting Files” and “Resources”)

Compiling a project for iOS it may happen that you get some warnings like this:

xcodebuild[5107:303392] warning:  The file reference for "/daten/_qt_workspaces/work_580/c2gQtCon_x/images.qrc" is a member of multiple groups ("Supporting Files" and "Resources"); this indicates a malformed project.  Only the membership in one of the groups will be preserved (but membership in targets will be unaffected).  If you want a reference to the same file in more than one group, please add another reference to the same path.

from QTCREATORBUG-14926: You can ignore this.

iOS Release Build Issues (Patch bitcode.prf)

So far all debug builds worked well. As next tested release builds and upload to GooglePlay BetaTest and Apple Testflight. Android Builds are running without any problems, but iOS Release Build filled my Issues Pane with 192 Issues – logging always:

:-1: warning: argument unused during compilation: '-fembed-bitcode-marker'

I created QTBUG-59352 – got info that similar bug was already reported (QTBUG-58754) and fixed: codereview

Fortunately this Warning again can be ignored. But it’s annoying building releases with hundreds of warnings. Thx to @jakepetroules I got  infos HowTo patch bitcode.prf. You’ll find this file here:

...sdk_580/5.8/ios/mkspecs/features/uikit/bitcode.prf

Open this file and replace the content by:

lessThan(QMAKE_XCODE_VERSION, "7.0") {
    warning("You need to update Xcode to version 7 or newer to support bitcode")
} else: !macx-xcode {
        # Simulator builds and all debug builds SHOULD use -fembed-bitcode-marker,
        # but unfortunately the -fembed-bitcode and -fembed-bitcode-marker driver
        # flags do not work in conjunction with -Xarch, so we'll have to let it use
        # the "wrong" flags for now (note that this issue affects only the Makefile
        # generator). We also don't want the flags to be passed in Xcode builds, as
        # the Xcode ENABLE_BITCODE setting will take care of that for us.
        release {
        QMAKE_CFLAGS           += -fembed-bitcode
        QMAKE_CXXFLAGS         += -fembed-bitcode
        QMAKE_OBJECTIVE_CFLAGS += -fembed-bitcode
        QMAKE_LFLAGS           += -fembed-bitcode
    } else {
        QMAKE_CFLAGS           += -fembed-bitcode-marker
        QMAKE_CXXFLAGS         += -fembed-bitcode-marker
        QMAKE_OBJECTIVE_CFLAGS += -fembed-bitcode-marker
        QMAKE_LFLAGS           += -fembed-bitcode-marker
    }
}

Now all -fembed-bitcode-marker issues are gone 🙂

Now we’re leaving the comfort zone.

Buttons remain some color of ripple effect

Suddenly I noticed a strange behavior in my more complex apps: Using the Drawer or Bottom Navigation Bar some color from pressing the buttons down remains after fingers are released. Fortunately this was fixed soon and the Drawer is working again (see patch)

Only one use-case left, where the Menu ToolButton remains some color:

toolbutton_clicked

Seems the ripple effect wasn’t reset completely while the Drawer is opening on top. At the moment I didn’t found a way to create a small test-case, but will try later agein.

Fortunately I found a workaround using a Loader toggling between two different Components of same ToolButton.

// ToolButton...
onClicked: {
        navigationBar.open()
        favMenuBugfix = !favMenuBugfix
    }

--------

Loader {
    id: favMenuLoader
    sourceComponent: favMenuBugfix? favMenuComponent1 : favMenuComponent2
}
Component {
    id: favMenuComponent1
    DrawerFavoritesMenuButton {
    }
}
Component {
    id: favMenuComponent2
    DrawerFavoritesMenuButton {
    }
}

Adding OpenSSL

As you probably know, Google removed openssl from Android7, so you have to add openssl libraries built by yourself.

My first projects with Qt 5.7 have used http only (they’re running behind firewalls on managed devices so this is secure)

All worked well without the need to add openssl – but it was on my ToDo list.

Qt 5.8 did some things different and now my Qt 5.8 apps are crashing from QNetworkAccessManager. From discussions in Qt Forums I’ve seen I’m not the only one seeing these differences between 5.7 and 5.8

There’s a documentation HowTo add OpenSSL support: http://doc.qt.io/qt-5/opensslsupport.html

unfortunately this fails on MacOS with error

unknown argument: '-mandroid'

long discussion in Qt Forum and on the Lists, but didn’t get it run – tried many hours. So I opened QTBUG-59375

finally from Android List I got a hint from Marco Piccolino and I found two .sh scripts doing the job.

More infos and HowTo use it in your own projects you’ll find at my github repo: https://github.com/ekke/android-openssl-qt

There are also some github projects providing prebuilt .so libraries, but I don’t want to include .so libs not built by myself from origin sources.

Hint: I got crash reports from users where openssl could crash if doing multi requests using QNetworkAccessManager. I had to add -DOPENSSL_THREADS. updated my github repo with the correct script: https://github.com/ekke/android-openssl-qt/commit/39d3d4122a132f1f73f7e7ed079de3f067775dde

Popup && Android Back Key problems

There was much work on Popups and (new with 5.8) Dialogs. Popups now also support ESC keys. But I run into two problems – see also QTBUG-59670

Popup without closePolicy: Android BACK quits the APP

There’s a new default closePolicy: Popup.CloseOnEscape | Popup.CloseOnPressOutside

But this doesn’t work on Android. Using Android BACK Key closes the APP without a chance to catch the key.

Workaround: set the policy explicitely – per ex. Popup.CloseOnPressOutside

Don’t use Popup.CloseOnEscape

Now this is working:

Keys.onBackPressed: {
 event.accepted = true
 // do something
}

Modal Popup doesn’t block Android BACK Key

Using a modal Popup this should block all Shortcuts and Back key.

But this doesn’t work using Android BACK Key. This time the key goes thru to Keys.onBackPressed.

Workaround: manage this blocking behavior by yourself.

Here’s the Popup:

Popup {
    id: popup
    modal: true
    closePolicy: Popup.NoAutoClose

    // your content

    onOpened: {
        appWindow.modalPopupActive = true

    }
    onClosed: {
        appWindow.modalPopupActive = false
    }
}

and in your main.qml:

ApplicationWindow {
    id: appWindow
    width: 410
    height: 680
    visible: true
    ...
    property bool modalPopupActive: false
    ...
    Keys.onBackPressed: {
        event.accepted = true
        if(appWindow.modalPopupActive) {
            showToast(qsTr("Back key not allowed"))
            return
        }
        ...
    }
}

QTBUG-59670 is classified as critical so I’m sure will be fixed for Qt 5.9

Text Selection Handles

There are some problems with Text Selection Handles – see next Page.


As I promised: updating your APP from 5.7 to 5.8 is mostly harmless 😉

I’ll tweet @ekkescorner if finding more issues while working on my apps and I’ll blog about new features like Dialogs and more.


← Back (Patch Qt 5.8)

→ Next Article (Text Selection Handles)

⇐ Home (Overview / Topics)