Issues and Workarounds (Update Qt 5.8.0 –> Qt 5.9.0)

June 23, 2017 — Leave a comment

Please read at first my blog HowTo install Qt 5.9.

Here are some issues and workarounds I found out while testing my apps under 5.9

 

Update QML Imports

This is always the first step after moving a project from 5.8 to 5.9: I’m updating the 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.8 to 5.9 I replaced

import QtQuick 2.8
import QtQuick.Controls 2.1
import QtQuick.Controls.Material 2.1

with

import QtQuick 2.9
import QtQuick.Controls 2.2
import QtQuick.Controls.Material 2.2

You can see the newest imports here.

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.

 

Drawer ignores taps outside the Drawer

Normaly if you opened a Drawer you can tap outside the Drawer to close. This works well up to 5.8.

Under 5.9 there’s a bug:

tapping outside the Drawer not always closes the Drawer.

This would be no big problem because you can drag the Drawer back or click inside the Drawer.

Unfortunately the Drawer ignores the Tap to close but the underlying (dimmed) Page gets touch events so users can by accident do something unwanted.

I opened QTBUG-61581.

I found a workaround to block those unwanted touch events on the Pages below the Drawer by inserting another Popup between Drawer und Pages below. looks ugly but it works in the meantime. The bug is classified as P1 so hopefully will be fixed soon.

Drawer {
    id: myDrawer
    z: 1
    ....
    // workaround:
    onOpened: {
        fakePopup.open()
    }
    onAboutToHide: {
        fakePopup.close()
    }
    Popup {
        id: fakePopup
        z: 0
        width: appWindow.width
        height: appWindow.height
    }
    // end workaround

 

Bug is only on Android and iOS – tested from macOS: MouseClick is working.

MonthGrid onClicked gets no events

I’m using MonthGrid as part of my DatePicker.

Works well up to 5.8 but now under 5.9 I’m getting no clicked events.

I opened QTBUG-61585. and also found an easy workaround: I added a MouseArea:

ApplicationWindow {
    visible: true
    width: 640
    height: 480
    title: qsTr("Hello World")
    id: appWindow

    Page {
        id: myPage

        GridLayout {
            columns: 3
            rows: 5
            width: appWindow.width
            height: appWindow.height

            MonthGrid {
                id: monthGrid
                Layout.fillHeight: true
                Layout.fillWidth: true

                onClicked: {
                    console.log("tapped on a date ")
                }

                delegate: Label {
                    id: dayLabel
                    text: model.day
                    font.bold: model.today? true: false
                    opacity: model.month === monthGrid.month ? 1 : 0
                    color: pressed ? Material.foreground : model.today ? Material.accent : Material.foreground
                    minimumPointSize: 8
                    fontSizeMode: Text.Fit
                    horizontalAlignment: Text.AlignHCenter
                    verticalAlignment: Text.AlignVCenter

                    background: Rectangle {
                        anchors.centerIn: parent
                        width: Math.min(parent.width, parent.height) * 1.2
                        height: width
                        radius: width / 2
                        color: Material.primary
                        visible: pressed
                    }
//                    MouseArea {
//                        anchors.fill: parent
//                        onClicked: {
//                            console.log("mouse area click")
//                        }
//                    } // mouse
                } // label in month grid

            } // month grid
        } // grid layout
    } // myPage
} // app window

Bug is only on Android and iOS – tested from macOS: MouseClick is working.

iOS Release Build: getting thousands of Warnings

While testing my APPs under 5.9 I noticed a strange behavior while doing a RELEASE build for iOS.

I’m getting many Warnings:

With some help from Jake Petroules I found a workaround:

ios {
...
 disable_warning.name = GCC_WARN_64_TO_32_BIT_CONVERSION
 disable_warning.value = NO
 QMAKE_MAC_XCODE_SETTINGS += disable_warning
...
}

I opened QTBUG-61587.

iOS: isOnline() not reliable from QNCM

Under Android it’s easy to know if the device is online: QNetworkConfigurationManager is your friend:

    mNetworkConfigManager = new QNetworkConfigurationManager(this);
    qDebug() << "INIT IS   O N L I N E ?" << mNetworkConfigManager->isOnline();

Up to iOS 10.2.1 with a little trick QNCM also could be used by observing active configurations and filter out a config with name “utun0”.

Now with iOS 10.3.2 I had devices also reporting an active configuration ‘en2’ even if iPhone was in airplane mode.

It’s better to rely on Apple’s Reachability Class.

see also QTBUG-56151 and this great article about “CheckingNetwork Status in iOS

here’s my workaround by including Reachability:

Download sources from attachment to bugreport.

Copy Reachability classes to <project>/ios/src

Change your .pro:

LIBS += -framework SystemConfiguration
....
ios {
 OBJECTIVE_SOURCES += ios/src/Reachability.mm \
 ios/src/ReachabilityListener.mm
...
}

add this include

#if defined (Q_OS_IOS)
#include "ios/src/ReachabilityListener.h"
#endif

change class definition:

class YourClass : public QObject
#if defined (Q_OS_IOS)
 , private utility::ReachabilityDelegate
#endif

add a statusChanged method:

#if defined (Q_OS_IOS)
void DataServer::statusChanged(utility::NetworkStatus newStatus)
{
 if (newStatus == utility::NotReachable) {
 // offline
 } else {
 // online
 }
}
#endif

Now you’re getting events if online state is changing on iOS devices.

At startup you can check the current state:

qDebug() << "I O S REACHABILITY: INIT IS O N L I N E ?" << status() != utility::NotReachable;

if you need some more informations you can check for different states:

#if defined (Q_OS_IOS)
    switch (status()) {
    case utility::NotReachable:
        networkInfo.append(tr("Internet not reachable"));
        break;
    case utility::ReachableViaWiFi:
        networkInfo.append(tr("WiFi internet connection"));
        break;
    case utility::ReachableViaWWAN:
        networkInfo.append(tr("mobile data internet connection"));
        break;
    default:
        break;
    }
#endif

This was the first time ever I’m using a ObjectiveC class 😉

I got warnings from Reachability.mm about unused parameters.

you can suppress these warnings by adding #pragma unused(theName)

static void PrintReachabilityFlags(SCNetworkReachabilityFlags flags, const char* comment)
{
#pragma unused(flags)
#pragma unused(comment)
#if kShouldPrintReachabilityFlags

Have tested Reachability under different situations at customer site and it’s working great.


Updating from 5.8 to 5.9 was easier and has less issues as my last update from 5.7 to 5.8

I’ll tweet @ekkescorner if finding more issues while working on my apps. Also I have to check all the issues I reported from 5.8 which ones are solved and which are still open.


← Back (Install Qt 5.9)

→ Next Article (Qt Creator Intro)

⇐ Home (Overview / Topics)


No Comments

Be the first to start the conversation!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s