Release 2.13.1: Qt Creator 4.4 Upgrade, Mac & Linux Improvements

V-Play 2.13.1 adds support for Qt Creator 4.4 and brings improvements for developers using Mac & Linux. There are also various other fixes and new improvements, for example for the Flurry and OneSignal Push Notifcation plugin.

Let’s get to the details of these improvements…

Qt Creator 4.4 Support

QtCreator 4.4 adds many improvements, especially for developers using C++ in their project. If you didn’t know yet: you can mix C++ and QML code in your V-Play projects. There will be an in-depth blog post how to do this soon!

Our favorite new feature is the new inline annotations in the code editor: errors and warnings are now also shown in the text line without hovering over them. This makes the warnings & errors easier to spot and helps to improve code quality!

Qt Creator 4.4 Inline Annotations

To enable the new annotations, run these steps:

  1. In Qt Creator, click on Help > About Plugins
  2. Enter “Clang” to the filter and enable the ClangCodeModel plugin to load
  3. Restart Qt Creator
  4. Enjoy the new awesome inline annotations :)

There is also a new syntax highlighting for C++ code available now. Local, global and member variables, functions, declarations and output arguments are now distinguishable by their highlighting in the editor. This makes the C++ code better readable and easier to understand.

For iOS & Android developers, these are the highlights:

  • New UI for managing simulator devices on iOS.
  • Added support for Android API levels 25 & 26.
  • Added option to run commands before the Android app starts and after it stopped.

For more details on the new Qt Creator release, see the Qt Blog announcement about it here.

Mac & Linux Improvements

With this update, developers on Mac & Linux have a new “V-Play Kit” available. The benefit of this new solution is, that updating to future V-Play versions that use a different Qt version internally gets a lot easier, because the Qt version is now automatically updated for you.

Important Notice for macOS and Linux Developers

Follow these steps on macOS and Linux because otherwise you will not be able to use the new features of this update and your existing projects will not compile without this change. This is a one-time step required to make updating V-Play versions easier in the future:

1.) After you updated V-Play, open Qt Creator and click on the “Projects” icon on the left. You will now see the new “V-Play Desktop” kit greyed out. Then double-click on the greyed out V-Play kit on the left.

V-Play 2.13.1 Mac & Linux Qt Creator Activate New Kit

After double-clicking on the (new) grey kit, it will be used by default for your project:

V-Play 2.13.1 Mac & Linux Qt Creator Activate New Kit 2

2.) To also set the new V-Play kit as the default for your future projects, click on Tools / Options and select Build & Run. Then select the V-Play Kit and click on the “Make Default” button. Now the new V-Play kit will be the default for all your future projects and it will look like this:

V-Play 2.13.1 Mac & Linux Qt Creator Default Kit Selection

Note: If you already have Qt installed on your PC, installing V-Play on top of your existing Qt installation also gets a lot easier with this new feature! You can add V-Play to your Qt project with this guide.

Flurry & OneSignal Push Notification Improvements

This update fixes an issue for the Flurry Analytics plugin, which caused a crash if you did not set an apiKey.

If you want to send push notifications with the OneSignal plugin to a specific user from the OneSignal dashboard or from your custom server, the userId property now works properly (it returned an empty string before).

Also, the nickname users can enter in the V-Play Game Network ProfileView, will now be stored as a push notification tag for this user. This allows you to send messages to users based on this additional information.

We also updated the OneSignal iOS SDK. If you are using OneSignal for sending push notifications in your app, please download the latest library from here.

You can see these new additions in the OneSignal Dashboard. In this screenshot, you can see the “Player ID” which is now available with the userId property. And the new tag “_vpgnnickname” stored for users who entered a manual nickname:

OneSignal Dashboard User Tag and Player ID

More Fixes & Improvements

Besides the highlights mentioned above, there are many other fixes and improvements for the SDK. Some of them are:

  • Optimize the AppListView cacheBuffer for better scrolling performance.
  • Add a new VPlayGameNetwork::defaultUserName property. Set this property to your preferred default name that users who have not set any custom userName get prepended their userId with. The default value for this property is “Player %1”. For example for an app and not a game, you could set this to “User %1”. Or if you only want to display the userId without any prefix, you can set it to “%1”.
    This enables a better user experience for V-Play apps using V-Play Game Network & V-Play Multiplayer for user login, user management, user authentication and chat messages.

For a full list of improvements and fixes to V-Play in this update, please check out our change log!

How to Update V-Play

Test out these new features by following these steps:

  • Open the V-Play SDK Maintenance Tool in your V-Play SDK directory.
  • Choose “Update components” and finish the update process to get this release as described in the V-Play Update Guide.

V-Play Update in Maintenance Tool

If you haven’t installed V-Play yet, you can do so now with the latest installer from here. Now you can explore all of the new features included in this release!

For Mac & Linux developers, follow the steps explained above.

 

 

More Posts Like This

How to Make Cross-Platform Mobile Apps with Qt – V-Play Apps

How to Make a Qt app

The post Release 2.13.1: Qt Creator 4.4 Upgrade, Mac & Linux Improvements appeared first on V-Play Engine.

Qt 5.6.3 Released

I am pleased to inform that Qt 5.6.3 has been released today. As always with a patch release Qt 5.6.3 does not bring any new features, just error corrections. For details of the bug fixes in Qt 5.6.3, please check the change logs for each module and known issues of Qt 5.6.3 wiki page.

Qt 5.6 LTS is currently in the ‘Strict’ phase, and only receives fixes to security issues, crashes, regressions and similar. Since end of 2016 we have already reduced the number of fixes going into the 5.6 branch and after Qt 5.6 LTS enters the ‘Very Strict’ phase it will receive security fixes only. The reason for gradually reducing the amount of changes going into an LTS version of Qt is to avoid problems in stability. While each fix as such is beneficial, they are also possible risks for behavior changes and regressions, which we want to avoid in LTS releases.

As part of our LTS commitment, we continue to support the commercial Qt 5.6 LTS users throughout the three-year standard support period, after which it is possible to purchase extended support. For description of our support services, please check the recent blog post describing the Standard, Extended and Premium Support. In May 2017 we released Qt 5.9 LTS, which includes a wide range of new features, functionality and overall performance improvements. We expect to release Qt 5.9.2 patch release still during September, including all the bug fixes of Qt 5.6.3 and many more. To learn more about the improvements that come with Qt 5.9 LTS you can find all relevant blogs and on-demand webinars here.   

If you are using the online installer, Qt 5.6.3 can be updated using the maintenance tool. Offline packages are available for commercial users in the Qt Account portal and at the qt.io Download page for open-source users.

The post Qt 5.6.3 Released appeared first on Qt Blog.

Qt Installer Framework 3.0.1 Released

We are happy to announce the release of Qt IFW 3.0.1.

3.0.1 is fully compatible with 2.0.5, which means you can update existing online installers with installers built with 3.0.1. Version 3.0.1 includes a lot of bug fixes and also new features.
Here is a list some new features, some to mention:

  • Allow to use the stylesheet to customize UI
  • New –silentUpdate command line option
  • Introduced gui.setTextItems() method
  • Add ApplicationsDirX86 and ApplicationsDirX64 predefined Variables.
  • Add new ‘–sign’ switch to binarycreator for signing OS X app bundles
  • Allow defining non-checkable items – introduces new element ‘Checkable’ for package.
  • Added support for setting descriptions of Windows shortcuts.
  • Add Castilian Spanish translation.

The full list of added features and bug fixed can be found from ChangeLog.

You can download Qt Installer Framework using Qt SDK or from QtAccount. Opensource version can be found also from Qt Downloads.

Thank you for everyone involved!

The post Qt Installer Framework 3.0.1 Released appeared first on Qt Blog.

Testing Applications for Color Blindness

At the Randa Meeting 2017 Volker and I decided to write a little KWin plugin. Activating this plugin you can simulate various types of color vision deficiencies, either on individual windows or full-screen. The plugin works by running a fragment shader on the respective window/screen.

Here is a short video demonstrating what we did:

The purpose is to allow everyone to test applications problematic color schemes.
https://en.wikipedia.org/wiki/Color_blindness

The post Testing Applications for Color Blindness appeared first on Qt Blog.

Accessibility improvements in Randa

Accessibility in KDE and Qt is constantly improving. Sometimes a change of scenery helps focusing and brings up productivity. Mix that with a bunch of great people and good things will start happening. It has been possible to create accessible Qt applications on Linux for a while, but of course not everything will just work out of the box untested. A while back Mario asked me to join this year’s Randa Meeting where KDE people discuss and fix issues. It turns out that was a great idea. I haven’t been able to focus much on applications and user experience lately, but with this backdrop it works 😉View of the mountains and Randa village

Upon arrival I sat down with Marco and David of Plasma fame and we quickly got Orca (the screen reader on Linux) working on their laptops. We discussed what is wrong and where improvements would be most needed for blind users to use the Plasma desktop, we got to work and had the first fixes even before lunch, wow. Adding a few accessibility hints and poking hard at keyboard navigation got us much further.

This means that KRunner – Plasma Desktop’s app launcher – is now much more accessible, a great enabler. There’s more work going into the menu and panel, hopefully we’ll see much improved keyboard usability for these by the end of the week. It’s good to see how Qt accessibility works nicely with Qt Quick.

In the afternoon, we had a round of introductions and talks. For accessibility some key points were:
– Don’t do custom stuff if you can avoid it. This includes colors and fonts, but also focus handling.
– Try running your application with keyboard only. And then mouse only.
– Make sure that focus handling actually works, then test with a screen reader.
– Oh, and focus handling. Check the order of your tab focus chain (in Qt Designer or by running your Qt Quick application. While I’ve lately become a big fan of the Qt Quick Designer, I don’t think it allows to detect all corner cases when it comes to tab key handling yet.)
– I should write and talk more about FocusScope, one our our best and most confusing one bit friends in Qt Quick.

Introductions in Randa

I sat down to poke at the systemsettings module, making it easier to debug and a bit more reliable. This morning I sat down with Ade to poke at why Calamares (the installer framework with the highest squid content ever) is not accessible. When running it as a regular user, the results were actually all in all quite OK. But it usually (for historical reasons) gets launched as root. While that may be fixed eventually, it was worth investigating what the issue really is, because, well, it should work. After a bit of poking, comparing DBus messages and then a break (Yoga and Acrobatics), we spotted that an old bug hadn’t actually been really fixed, just almost. Applications run as root would connect to the right DBus bus (AT-SPI2 runs its own bus), but we just failed to actually initialize things properly. Turns out that in this slightly different code path, we’d emit a signal in a constructor, before it was connected to the receiver… oops. The fix is making its way into Qt as we speak, so everything is looking and sounding good 🙂

[Note: the blog post was written yesterday, but I never got around to publishing it, so everything is off by a day, just shift it back by one day. Then you can imagine how I will sit down the next evening for a bit of late night blogging and pancakes (that’s about now).]

The post Accessibility improvements in Randa appeared first on Qt Blog.

Qt 5.10 Alpha Released

I can proudly tell that Qt 5.10 Alpha is released today.

Please check Qt 5.10 New Features -wiki to see what new is coming with Qt 5.10 release. And as usual the official Alpha is a source code delivery only.

Next milestone in our way to final Qt 5.10 release (which is planned to happen at the end of November) will be first Beta release. We are targeting to get it out soon after the Alpha. We will release several Beta releases in similar manner as we did with Qt 5.9 – made available via the online installer. Each new Beta release will add maturity and improvements based on user feedback.

Please download the Qt 5.10 Alpha source packages from your Qt Account or from download.qt.io.

Most importantly, remember to give us feedback by writing to the mailing lists and reporting bugs.

 

 

The post Qt 5.10 Alpha Released appeared first on Qt Blog.

Qt World Summit is Coming

Qt World Summit 2017 is now exactly a month away. Time to get prepared for the event.

If you haven’t yet gotten your tickets, now it is time to visit the registration site.

This year we will have seven incredible tracks of talks ranging from automation to deep dive tech talks.

KDAB is hosting the Qt Training day. The topics range from introductory courses on Qt and QML to more complex topics like modern OpenGL and C++14 and C++17. ICS is joining the Qt Training Day with a training on user experience design for embedded devices.

Don’t forget Contributors’ Days at the beginning of the event. While it is aimed at people contributing code, documentation or their time to the Qt project, it is a fun event for anyone who is deep in Qt coding. The chance to follow core developers present their views on the inner working of Qt and the discussions arising from the talks are definitely worth hearing.

To attend the Contributors’ Days for free, you can use this link to unlock the free Contributors’ Days pass.

No matter which part you’ll be attending, I’m looking forward to seeing you all in Berlin!

The post Qt World Summit is Coming appeared first on Qt Blog.

Qbs 1.9 released

Qbs (pronounced “Cubes”) is The Qt Company’s latest build tool, which aims to be the replacement for qmake in the Qt build system. In addition to its use within Qt, for our customers Qbs will also provide faster build times coupled with a rich feature set in order to reduce build engineering complexity and decrease time to market.

Today I’m excited to introduce you to the latest release of Qbs – 1.9. This is an important release with foundational new features.

What’s New?

In addition to the usual bug fixes and performance enhancements, this release includes two of the most foundational changes to the future of Qbs.

Language Improvements

The first of these is something we call Dependency Parameterization. Depends items can now be parameterized to set special module parameters for one particular product dependency. The new item type, Parameter, is used to declare such parameters in a module, while the new item type Parameters (note the ‘s’) is used to allow products to set default values for such parameters in their Export item.

So, what can dependency parameterization do for you? First, let’s step back and examine the meaning and usage of a Depends item.

Depends items are used to create a dependency between product A and product B, such that the target artifacts of the dependency can be used as inputs to the rules in the context of the depending product. In practice, Depends items have so far been used mostly to link an executable or library to another library. But a dependency is a very abstract concept, and can represent any type of relationship between two products. The fundamental problem is that whatever the meaning of the dependency, how that dependency took effect was only controllable from one side of the dependency relationship – the dependency’s side.

Qbs 1.9 allows this relationship to be controlled from the depending product’s side as well. For example, one of the products in your project may be a plugin which is implemented as a shared library. Your main application should depend on that plugin, because you want to ensure the plugin is built whenever the main application is, but you don’t want to directly link to that plugin because you want to load it entirely at runtime.

In Qbs 1.8, we would create a Depends items pointing to our shared library, like so:

Depends { name: "library" }

But there’s a problem – now our main application will actually link against the plugin shared library, which we don’t want. This is why we need to control the dependency relationship from the depending product’s side as well. In Qbs 1.9, we can now add a dependency parameter to the Depends item, like so:

Depends { name: "library"; cpp.link: false }

This tells Qbs that we want to depend on the “library” product, but don’t want to actually link to it. This gets exactly the result we want – ensuring that “library” is built whenever our main application is, but without creating a direct linking relationship between the two.

So how does it work? First, the cpp module in Qbs declares the availability of a boolean dependency parameter called “link”, using the Parameter item. Whenever a Depends item sets this property, its value will be applied to any input artifacts coming from the target artifacts of that product, when the current product’s rules are processed. The linker Rule in the cpp module then checks the cpp.link parameter of any dependent shared libraries and only links to them if it is true.

You might ask, why go through the trouble of extending the language in this way if we could just express within “library” itself that it should not be linked? Perhaps via using a different file tag for the output? The reason is that you might have multiple products A and B within your project that want to depend on another product C, but A and B both want to depend on C in a different way. For example, if C is a macOS dynamic framework, B might want to Depend on C by linking to it, because B is another library which depends on some of C’s functionality, whereas A is an application bundle that wants to depend on C by embedding it within itself, but not by linking to it, since the A application doesn’t directly call any functions in C.

The dependency parameter that we’ve added so far are cpp.link, cpp.linkWholeArchive, and cpp.symbolLinkMode. Check out the cpp module documentation to find out how you can use them in your projects.

Essentially, Depends items now provide a much more flexible way for build engineers to express the relationship between products, leading to more correct and efficient builds, without complicated hacks and workarounds.

Multiplexing

The other important new feature we have is called Product Multiplexing. This feature replaces and is functionally a superset of the old profile multiplexing functionality we had previously implemented in order to support multi-architecture Android APKs.

The new implementation has been generalized to cover more use cases, and is a lot more powerful. Its primary function is to allow the creation of multi-architecture Android APKs and the creation of multi-architecture “fat” binaries and multi-variant frameworks (where a single framework can contain both a release and debug build of a library) on Apple platforms. We can also easily extend the multiplexing to more areas solely using QML, without having to modify the core build engine.

The problem with the old profile multiplexing is that it enforced a rigid project structure that was inherently dependent on the naming convention of the build profiles that were used. Such a structure wasn’t in keeping with our philosophy to make profiles optional, nor did it play particularly nice with how Qt Creator handles Qbs-based projects.

Enter product multiplexing: instead of multiplexing a product over multiple profiles, we now allow a product to be multiplexed over a number of more general properties. Currently, these are qbs.architectures (which maps to qbs.architecture), qbs.buildVariants (which maps to qbs.buildVariant) and qbs.profiles (which maps to qbs.profile, hence keeping a certain degree of backwards compatibility with the old multiplexing as well).

Product multiplexing works by examining a special property on the Product item called multiplexByQbsProperties, which can be set to the list of properties your product should multiplex over. For example, let’s say multiplexByQbsProperties contains two strings “architectures” and “buildVariants”. Qbs will then evaluate the values of qbs.architectures and qbs.buildVariants, which in turn may contain the values, [“x86”, “x86_64”] and [“debug”, “release”]. Qbs will then build the product N times according to the number of values in the matrix. In our example, 4 configurations of the product will be built: (x86, debug), (x86, release), (x86_64, debug), and (x86_64, release). If the Product’s aggregate property is true, the product will also be built a fifth time, where the values of the multiplexed properties are left undefined. The aggregate product will have an automatic dependency on the original four instances of the product, allowing it to collect and operate on their outputs artifacts.

The aggregate product is used in situations where the target artifacts of the individually multiplexed instances must be combined into one final aggregate artifact that makes up the overall product. For example, bundle products on macOS, iOS, tvOS, and watchOS use the aggregate product to create the bundle artifacts like Info.plist, PkgInfo, etc., which aren’t dependent on a particular architecture or build variant, and also use the lipo tool to join together the built native code for different architectures (like x86 and x86_64) into the final, multi-architecture “fat binary” that goes inside the app bundle or framework.

Due to its general design and easily extensible implementation in the build engine, we hope that in the future we can discover even more use cases for product multiplexing. One case I’ve considered so far but have not yet investigated is building multi-architecture app bundles for the Universal Windows Platform.

Deployment and Packaging

One of the interesting new features with this release is the ability to build macOS disk images with custom backgrounds and icon layouts.

Most applications on macOS are installed via a .dmg file, which is usually customized by a fancy image background and custom icon layout. The problem is, it’s quite challenging to construct such DMG files correctly. The custom background and icon layout relies on several undocumented proprietary file formats, some of which date back to the Mac OS Classic days, and which are even nested within one another.

Most of the existing tools to create DMG files do so by using AppleScript to manipulate the Finder graphically to generate the right icon layout, which is both unstable and incompatible with headless build servers since the necessary OS services to launch graphical applications may not be running at all. Other solutions will try to create the primary .DS_Store file manually, and commit to their source repository. This binary blob is difficult to inspect and edit, and might not be backwards compatible with older versions of the OS, depending on how it was generated.

The solution used by Qbs suffers none of these problems. It generates the necessary files programmatically, in an entirely reproducible manner, and there are no external dependencies that need to be separately installed and zero binary blobs committed to your source repository. It Just Works. Transform this:

AppleApplicationDiskImage {
    targetName: "cocoa-application-" + version
    version: "1.0"

    files: [
        "CocoaApplication/dmg.iconset",
        "CocoaApplication/en_US.lproj/LICENSE",
        // comment out the following line to use a solid-color background
        // (see dmg.backgroundColor below)
        "CocoaApplication/background*"
    ]

    dmg.backgroundColor: "#41cd52"
    dmg.badgeVolumeIcon: true
    dmg.iconPositions: [
        {"x": 200, "y": 200, "path": "Cocoa Application.app"},
        {"x": 400, "y": 200, "path": "Applications"}
    ]
    dmg.windowX: 420
    dmg.windowY: 250
    dmg.windowWidth: 600
    dmg.windowHeight: 422 // this *includes* the macOS title bar height of 22
    dmg.iconSize: 64
}

…into this:

macOS disk image built with Qbs

macOS disk image built with Qbs

Qbs even supports multi-language license agreement prompts that appear when the DMG is opened,  with full Unicode and rich-text formatting support. And no, you don’t have to deal with Carbon resource files from Mac OS Classic to do it!

In order to implement this functionality, we made use of several high quality Open Source Python modules (dmgbuild, ds_store, and mac_alias). I’d like to thank the developer, Alastair Houghton, for his hard work on and maintenance of these modules. The Qt Company has also contributed back a number of fixes and enhancements to these modules as part of the development of this feature.

Other New Features

  • Setting module property values from the command line can now be done per product
  • When rebuilding a project, the environment, project file, and property values are now taken from the existing build graph, which makes builds more self-contained and reliable
  • Rules now have a property requiresInputs. If it is false, the rule will be run even if no artifacts are present that match its input tags
  • Precompiled headers are now used by default if present in the product (cpp.use*PrecompiledHeader defaults to true now)
  • Added support for Unified Headers in the Android NDK
  • The property cpp.cxxLanguageVersion now gets mapped to MSVC’s /std option, if applicable
  • Added a new How-To section in the documentation with step-by-step guides on how to achieve common workflows
  • Context-sensitive help is now enabled for Qbs items in Qt Creator 4.4, which includes Qbs 1.9

Also, the loadFile() and loadExtension() function have now been formally deprecated and replaced by require(), as originally stated in the Qbs 1.8 release blog.

Try It!

The Open Source version is available on the download page, and you can find commercially licensed packages on the Qt Account Portal. Please post issues in our bug tracker. You can also find us on IRC in #qbs on chat.freenode.net, and on the mailing list. The documentation and wiki are also great places to get started.

Qbs is also available on a number of packaging systems (Chocolatey, MacPorts, Homebrew) and updated on each release by the Qbs development team. It can also be installed through the native package management system on a number of Linux distributions including but not limited to Debian, Ubuntu, and Arch Linux. An official Fedora package is in progress and should be available in a future release of Fedora.

Qbs 1.9 is also included in Qt Creator 4.4, which was also released today.

The post Qbs 1.9 released appeared first on Qt Blog.

Qt Creator 4.4.0 released

We are happy to announce the release of Qt Creator 4.4.0!

Qt Creator inline annotations

Editing

If you are using the Clang code model or bookmarks, there are new inline annotations in the editor. Bookmarks and Clang errors and warnings are now also shown at the end of the corresponding text line in the editor. This way, you can easily see the details of issues while you type, without the need to hover your mouse over underlined text or the marker on the left side. You can configure the position of the annotations in the Options > Text Editor > Display. (You can also turn the feature off there, if you don’t like it.)

We also added the option to smoothly scroll to the new location if you jump to a different place in the same file. If you like to try this feature, turn it on in Options > Text Editor > Display > Animate navigation within file.

C++

We enabled some highlighting features that were already available, but didn’t have their own color set in the default color scheme. Local, global and member variables, functions, declarations and output arguments are now distinguishable by their highlighting in the editor. In case that is too colorful for you, we made the more modest previous scheme available as Default Classic in Options > Text Editor > Fonts & Colors.

When you rename a class, Qt Creator now offers to rename files with the same base name as well. Just check the Rename files option in the search result panel before pressing the Replace button.

If you have the Clang code model enabled, this is now also used for the highlighting of the identifier at the text cursor, which was previously still using the built-in model in any case.

CMake

Qt Creator CMake project treeWe did some cleanup of the project tree when using CMake >= 3.7 (“server-mode”). It now defaults to hide empty directories, and the source files moved one level up, getting rid of the additional <Source Directory> node. We also fixed the application’s working directory when a CMAKE_RUNTIME_OUTPUT_DIRECTORY is specified, and that it was not possible to accept external changes from the CMake configuration has changed on disk dialog.

Other changes

We removed the unmaintained support for Windows CE, and changed the ClearCase integration to be disabled by default.

This is just a small selection of the changes and improvements done in 4.4. Please have a look at our change log for a more detailed overview.

Get Qt Creator 4.4.0

The opensource version is available on the Qt download page, and you find commercially licensed packages on the Qt Account Portal. Qt Creator 4.4.0 is also available through an update in the online installer. Please post issues in our bug tracker. You can also find us on IRC on #qt-creator on chat.freenode.net, and on the Qt Creator mailing list.

The post Qt Creator 4.4.0 released appeared first on Qt Blog.

QtLocation 5.9

With Qt 5.9, the QtLocation module has received a substantial amount of new features, as briefly summarized in the release post. The goal of this post is to provide additional details about what’s now possible with QtLocation 5.9.

Rotating and tilting maps

One long-standing limitation of the built-in tile renderer was the inability to draw rotated or tilted maps and map items. We finally removed this limitation, and in 5.9 maps as well as the map items added to them can be rotated and tilted. This also applies to MapQuickItems, which can be tilted by setting the appropriate zoomLevel value to them. With the support for tilting and rotation come two new dedicated gestures in the gesture area of the map: two fingers rotation, and two fingers vertical drag for tilting.

It is now possible to rotate and tilt maps. Items on it will be transformed accordingly. In this figure a MapQuickItem embedding a QtMultimedia Video element is used to overlay a video of the shore.

It is now possible to rotate and tilt maps. Items on it will be transformed accordingly. In this figure a MapQuickItem embedding a QtMultimedia Video element is used to overlay a video of the shore.

In addition to this, a new fieldOfView property has been added to the Map, to control the camera field of view when the map is tilted. Note that this property, like the tilt and the zoomLevel properties, have lower and upper bounds. In some cases these bounds will prevent changing the property (e.g., a plug-in using a third-party renderer that does not allow changing the field of view will return a lower bound for the field of view equal to the upper bound).

Tile overzooming

Another long-standing limitation that got us many complaints over the last years was the inability of using cached data to approximate tile content not yet provisioned.
Lower zoom level tiles are now used to approximate higher zoom levels tiles, until these are fully provisioned. This finally prevents, where possible, the appearance of empty tiles revealing the (usually gray) background.

The difference in loading the map tiles, 5.8 (top) vs 5.9 (bottom)

The difference in loading the map tiles, 5.8 (top) vs 5.9 (bottom)

Improved third party map renderer support and the MapboxGL plugin

Prior to 5.9, the only way to display a map using QtLocation was to cut it into raster tiles, and feed the tiles to the built in tiled map renderer. Some have created plug-ins that embedded third party map renderer, but in the end they all had to do the rasterization-to-tiles step, in order to get the map on the screen.

QtLocation 5.9 removes this roadblock, allowing to draw custom QSG nodes in a custom QGeoMap implementation, so that it is finally possible to plug a third party renderer directly into the QtQuick scene graph.
This can be done in different ways, the most common being rendering the map off-screen into a texture, and then rendering the texture in the QtQuick scene graph, or using a QSGRenderNode to issue graphics commands directly.
The second approach is more efficient, but also more complex to set up and with more corner cases to handle.

How this performs can be seen by trying out the new Mapbox GL plugin, that, in cooperation with Mapbox, has been included in Qt for most of the supported platforms. This plug-in renders Mapbox Vector Tiles using the mapbox-gl-native renderer, supporting both online and offline map sources. This plug-in also allows to select either of the two rendering approaches mentioned above (although it should be noted that the QSGRenderNode approach is experimental and may introduce problems).

The MapboxGL plugin in action

The MapboxGL plugin in action

Handing map items rendering over to the plug-in

In addition to handing the map rendering over to the plug-in, it is also possible for a QGeoMap implementation to define which types of map items it can to render by itself. With QtLocation 5.9, if a plug-in instantiates a QGeoMap that reports the ability of drawing MapPolylines, these items are handed over to the plug-in, and the default rendering path for items of that type will be disabled. They will behave just like before, but their visual appearance will depend entirely on how the plug-in renders them. The MapboxGL plugin can, for example, render native MapRectangles, MapCircles, MapPolylines and MapPolygons. They will be anti-aliased and their style can be customized using Mapbox style specifications.
On the downside, the rendering of these items entirely depends on the plugin. So, on a MapboxGL map for example, they not support borders, so setting border properties on the items will have no effect. They also do not currently support visiblity and opacity for the items, although this is something that may get fixed very soon.

MapPolyline rendered on a map using the MapboxGL plugin. The polyline has been styled using MapParameters

A MapPolyline rendered on a map using the MapboxGL plugin. The polyline has been styled using MapParameters

Exposing Plug-in – specific mapping features

Enabling the integration of third-party mapping engines opens up for the opportunity of using features that are specific to the one or the other engine. For example, the mapbox-gl-native library offers a very flexible API for changing the style of map elements at runtime.
To allow plugins to expose engine-specific features, we have introduced a new QML type, MapParameter. Elements of type MapParameter are essentially duck-typed, as properties have to be defined by the programmer according to what the documentation of the plug-in requires. In the case of the Mapbox GL plugin, a map parameter to control the visibility of a Mapbox style layer named “road-label-small” would look like this:

MapParameter {
    type: "layout"
    property var layer: "road-label-small"
    property var visibility: "none"
}

Note that properties in map parameters are dynamic. They can be changed at runtime and the effects will be immediate.

Improved stacking of multiple Maps

Combining multiple map layers has been challenging with the previous Qt releases. That’s because different Map elements would have different zoom level ranges, and these ranges would also be enforced. In addition, map copyright notices could only be turned on or off, with the result of having them overlapping on screen.
In 5.9 the Map element allows the zoomLevel property to go beyond the minimum or maximum supported zoom levels, if set programmatically (that is, not through mouse or gestures interaction) and the used plug-in supports overzooming.
This way it is possible to use property bindings on the zoomLevel property of all the overlay maps to be driven by the value in a base map “layer”.

In addition, it is now possible to manually add elements of type MapCopyrightNotice on top of the maps, and source their content from the map elements. In this way they can be freely arranged, and also styled using custom CSS code.

Finally, one problem that was previously common when changing maps at runtime was that map items added to a map would be gone when the map would be replaced with another map sourced from a different plug-in.
For this reason, we include a new plug-in called itemsoverlay, whose only purpose is to provide a completely empty, transparent, map that costs almost nothing to render. The intended use is to have one Map element using this plug-in on top of the map stack, where to keep map items, so that the layers underneath can be freely removed.

Other improvements

A new method, fitViewportToVisibleMapItems, has been added to the Map element, to only consider visible items when fitting the viewport. A new QML type, MapItemGroup, has been introduced, to combine multiple map items together, like in a separate qml file. Note that it is currently not possible to use MapItemGroups in combination with MapItemViews.

The post QtLocation 5.9 appeared first on Qt Blog.

Announcing Sticklyst - leveraging KDE Frameworks on the Web

Sticklyst is a web paste tool, like pastebin, Stick Notes (paste.kde.org), build with Cutelyst and KDE Frameworks.

Building this kind of tool has been on my TODO list for a long time, but never really put some effort into it. When the idea first came by, I decided to look at the code of http://paste.scsys.co.uk/ which is powered by a Perl Catalyst application, to my surprise the Perl module that handled syntax highlighting was a port of the code of Kate, and it even said it used Kate's definitions.

If that code used Kate's, I'd better use the code directly, I hoped it wouldn't be too coupled with GUI classes, but failed to find the code. A week ago I saw a mention about this on KDE's mailing list, so with a little help from some IRC fellows I met the https://cgit.kde.org/syntax-highlighting.git/ code.

Then thanks to some tips from Volker Krause who showed me how to use it without GUI widgets, I managed to build a simple web app, which I presented live on the first Qt conference here in Brazil at São Paulo https://br.qtcon.org/.

Just for record the application uses less than 3MB of RAM and renders quickly using a sqlite db for the storage.

The code is 90% completed, is on production at https://paste.cutelyst.org/, and is now up for adoption. Basically someone willing to take care of it could implement the following missing features compared to Stick Notes:

  • Extra database support
  • URL shortener
  • User authentication

The list is short and the code is clean, go test, break, hack:

https://github.com/cutelyst/sticklyst

Have fun!

A new QProcess::startDetached

From Qt 5.10 on, there is a new way how to start detached processes with QProcess.

Of course you know this, but let me quickly repeat what a detached process is. If you start a program using QProcess without detaching, then the destructor of QProcess will terminate the process. In contrast, a detached process keeps running unaffected when the calling process exits. On Unix, a detached process will run in its own session and act like a daemon.

Traditionally, we start detached processes with the static QProcess::startDetached() method.

QProcess::startDetached("aplay tada.wav");

There is a second overload that supports passing a separate argument list and the working directory. It also lets us retrieve the PID of the started process.

qint64 pid;
QProcess::startDetached("mpg123", {"Jeopardy_Theme.mp3"}, musicDirPath, &pid);
printf("Performing a lengthy calculation...");
calculateDeterminant(reallyBigMatrix);
puts("done.");
QProcess::startDetached("kill", {QString::number(pid)});

This little example crunches numbers for a while and plays the Jeopardy Theme to entertain the user. When the calculation result is ready, it kills the music player using the obtained PID.

When running this example on Linux, you will notice a little annoyance: we have no way of suppressing the output of the detached process.
(Okay, this particular tool has the “–quiet” option, but let’s ignore that for the example’s sake.)

Qt Users have requested for a long long time the ability to

  • set the process environment,
  • redirect stdin, stdout, stderr to files
  • and set native arguments and the CreateProcess argument modifier on Windows

for detached processes.

All this is now possible in Qt 5.10! But instead of adding a monstrous overload for the static startDetached() method, we added a non-static QProcess::startDetached(qint64 *pid). This new member function reads the properties of your QProcess object and starts the to-be-detached process accordingly. It can be used as follows:

QProcess process;
process.setProgram("mpg123");
process.setArguments({"Jeopardy_Theme.mp3"});
process.setWorkingDirectory(musicDirPath);
process.setStandardOutputFile(QProcess::nullDevice());
process.setStandardErrorFile(QProcess::nullDevice());
qint64 pid;
process.startDetached(&pid);
...

The redirection to /dev/null makes sure that the user is not disturbed by visual output of the audio player.

Only a certain sensible subset of functions is supported for startDetached():

  • setArguments()
  • setCreateProcessArgumentsModifier()
  • setNativeArguments()
  • setProcessEnvironment()
  • setProgram()
  • setStandardErrorFile()
  • setStandardInputFile()
  • setStandardOutputFile()
  • setWorkingDirectory()

All other properties of the QProcess object are ignored.

If there are more properties to be supported in the future, they can be easily added in the implementation of the new startDetached().

Happy detaching!

The post A new QProcess::startDetached appeared first on Qt Blog.

Release 2.13.0: Free Rewarded Videos & Native Ads for Google AdMob and Qt

V-Play 2.13.0 adds rewarded videos and native ads as two more ad types to the free AdMob Plugin. This allows you to better monetize your app or game and enables you to earn more revenue from your app! This update also adds support to get the phone contact list on Android & iOS and to get the phone number of the user’s mobile device.

Rewarded Videos

The new AdMobRewardedVideo component allows you to reward users for watching a full-screen interstitial ad in full length. The ad is either a skippable video or an interactive ad.

Rewarded Video AdMob Example

You can choose how this reward looks like: give away some virtual currency, virtual items or unlock features within your app or game are popular examples. Here is an example how you can give the user virtual currency:

import VPlay 2.0
import VPlayPlugins 1.0
import QtQuick 2.0

Item {

  // start currency
  property int currency: 20

  AdMobRewardedVideo {
    id: myRewardedVideo

    // test ad for rewarded videos
    adUnitId: "ca-app-pub-3940256099942544/5224354917"

    onRewardedVideoRewarded: {
      currency += 10
    }

    // load interstitial at app start to cache it
    Component.onCompleted: {
      loadRewardedVideo()
    }

  }

  ButtonVPlay {
    text: "Simulate Level Completed"
    onClicked: {
      // each level "costs" 1 currency
      currency--

      if(currency < 10) {
        // show the new video if user is below 10 credits
        myRewardedVideo.showRewardedVideoIfLoaded()

        // load a new video every time it got shown, to give the user a fresh ad
        myRewardedVideo.loadRewardedVideo()
      }
    }
  }

  ButtonVPlay {
    text: "Simulate In-app purchase 1000 Credits"
    onClicked: currency += 1000
  }

}

With this example code, you can motivate users to watch an ad because they get something for it. Those users who do not want to watch an ad, can also purchase a virtual currency with the above code example. By only showing the ad if the user is below a certain virtual currency threshold, you guarantee users who bought a virtual currency pack do not see the ad.

We have this mechanism in place in the popular One Card game – you can use its full source code and copy it to your app. This also includes a real in-app purchase implementation with our free in-app purchase plugin.

Why and When to Use Rewarded Ads

Rewarded ads are the preferred way to use mobile ads these days, so we highly recommend to use this feature in your apps. The perfect time to show a rewarded ad is when a user navigates between pages or screens of your app. For example after he finished a game or after he had a “success moment” like completing a level. You could motivate the user even more to watch an ad by giving extra benefits after such a success moment. This helps you to earn money, while on the other hand giving a benefit to the user – a win-win situation.

The AdMobRewardedVideo component is part of the free AdMob plugin. See here how to add the AdMob plugin into your app.

Native Ads

You can now use native ads with the new AdMobNative component for the Google AdMob Plugin. Native banner ads are a more flexible way to show ad banners. They can have any position, width, height, color and text placement so you can better fit them into your user interface. You can even use them for example as list items in a ListView, like Facebook is doing this in the user timeline of their mobile app.

There are three different template types (small, medium and large) to select from. Each of the template types have different ranges for their size, for example a small ad must have a height of at least dp(80).

AdMob Native Ad Small Size Templates

For complete control over the appearance, you can customize the CSS code. If you do not want to write any CSS on your own, the templates can be used as they are and their styling can be customized in the AdMob backend with a visual ad template editor. In the template editor, you can choose various colors for the template and preview it for specific sizes:

CSS Styling Native Ads AdMob

In comparison to standard banner ads, native ads require a little bit more work to setup, but have a much better user experience because the ad blends into your app’s user interface.

Supported Ad Types of the Google AdMob Plugin

With these 2 new ad types, you can now use ALL of the available ads from Google AdMob: banner ads, full-screen interstitial ads, rewarded videos and native ads:

AdMob Banner Types

All of these ad types are part of the V-Play AdMob Plugin. See here how to add the V-Play plugin to your app or game. The AdMob Plugin is available for free for all V-Play developers!

If you have an existing Qt app/game and would like to add the AdMob plugin but no other V-Play components, you can find a guide how to add the AdMob plugin to your Qt based app here.

Get Contact List and Phone Numbers on iOS & Android

With this update, you are able to get the mobile device’s contact list on iOS & Android with a single call to NativeUtils::getContacts(). This allows you to create a messenger app like WhatsApp, where users can see who of their contacts also use your app.

Here is an example how to display all contacts in a list:

import VPlayApps 1.0

App {
  AppListView {
    anchors.fill: parent
    model: nativeUtils.getContacts()

    delegate: SimpleRow {
      text: modelData.name
      detailText: modelData.phoneNumber
    }
  }
}

And this is how the above code looks like on iOS:

Get Contacts List iOS

More Fixes & Improvements

Besides the highlights mentioned above, there are many other fixes and improvements for the SDK. For a full list of improvements and fixes to V-Play in this update, please check out our change log!

How to Update V-Play

Test out these new features by following these steps:

  • Open the V-Play SDK Maintenance Tool in your V-Play SDK directory.
  • Choose “Update components” and finish the update process to get this release as described in the V-Play Update Guide.

V-Play Update in Maintenance Tool

If you haven’t installed V-Play yet, you can do so now with the latest installer from here. Now you can explore all of the new features included in this release!

Important Notice for Windows Developers

Follow these steps on Windows, because otherwise you will not be able to use the new features of this update but still are on the previous V-Play version 2.12.2. This is a one-time step required to make updating V-Play versions easier in the future:

1.) After you updated V-Play, open Qt Creator and click on the “Projects” icon on the left. You will now see the new “V-Play Desktop” kit greyed out. Then double-click on the greyed out V-Play kit on the left.

Click on new kit to active

After double-clicking on the grey kit, it will be used by default for your project:

New Kit Selected

2.) To also set the new V-Play kit as the default for your future projects, click on Tools / Options and select Build & Run. Then select the V-Play Kit and click on the “Make Default” button. Now the new V-Play kit will be the default for all your future projects and it will look like this:

New V-Play Kit is default

 

 

More Posts Like This

How to Make Cross-Platform Mobile Apps with Qt – V-Play Apps

How to Make a Qt app

Release 2.11.0: All Monetization Plugins Now Free, Plugin Trial & Firebase Qt Plugin

Release 2_11

WeAreDevelopers Conference App – Open Source & Live Now!

WeAreDevelopers

The post Release 2.13.0: Free Rewarded Videos & Native Ads for Google AdMob and Qt appeared first on V-Play Engine.

Building Qt on Debian

I recently followed the advice of @sehurlburt to offer help to other developers. As I work with Qt and embedded Linux on a daily basis, I offered to help. (You should do the same!)

As it is easy to run out of words on Twitter, so here comes a slightly more lengthy explanation on how I build the latest and greatest of Qt for my Debian machine. Notice that there are easier ways to get Qt – you can install it from packages, or use the installer provided from The Qt Company. But if you want to build it yourself for whatever reason, this is how I do it.

First step is to get the build dependencies to your system. This might feel tricky, but apt-get can help you here. To get the dependencies for Qt 5, simply run sudo apt-get build-dep libqt5core5a and you are set.

Next step would be to get the Qt source tarball. You get it by going to https://www.qt.io/download/, select the open source version (unless you hold a commercial license) and then click the tiny View All Downloads link under the large Your download section. There you can find source packages for both Qt and Qt Creator.

Having downloaded and extracted the Qt tarball, enter the directory and configure the build. I usually do something like
./configure -prefix /home/e8johan/work/qt/5.9.0/inst -nomake examples -nomake tests. That should build everything, but skip examples and tests (you can build these later if you want to). The prefix should point to someplace in your home directory. The prefix has had some peculiar behaviour earlier, so I try to make sure not to have a final dash after the path. When the configuration has been run, you can look at the config.summary file (or the a bit higher up in the console output) and you can see a nice summary of what you are about to build. If this list looks odd, you need to look into the dependencies manually. Once you are happy, simply run make. If you want to speed things up, use the -j option with the highest number you dare (usually number of CPU cores plus one). This will parallelize the build.

Once the build is done (this takes a lot of time, expect at least 45 minutes with a decent machine), you need to install Qt. Run make install to do so. As you install Qt to someplace in your home directory, you do not need to use sudo.

The entry point to all of Qt is the qmake tool produced by your build (i.e. prefix/bin/qmake). If you run qmake -query you can see that it knows its version and installation point. This is why you cannot move a Qt installation around to random locations without hacking qmake. I tend to create a link (using ln -s) to this binary to somewhere in my path so that I can run qmake-5.9.0 or qmake-5.6.1 or whatnot to invoke a specific qmake version (caveat: when changing Qt version in a build tree, run qmake-version -recursive from the project root to change all Makefiles to the correct Qt version, otherwise you will get very “interesting” results).

Armed with this knowledge, we can go ahead and build QtCreator. It should be a matter of extracting the tarball, running the appropriate qmake in the root of the extracted code followed by make. QtCreator does not have to be installed, instead, just create a link to the qtcreator binary in the bin/ sub directory.

Running QtCreator, you can add Qt builds under Tools -> Options… -> Build & Run. Here, add a version by pointing at its qmake file, e.g. the qmake-5.9.0 link you just created. Then it is just a matter of picking Qt version for your project and build away.

Disclaimer! This is how I do things, but it might not be the recommended or even the right way to do it.

2017 for Qt Contributors

This is a good year to be a Qt contributor.

There was Qt Day Italy in June. From what I hear, the event was a success. The talks were great and everything worked. This was the sixth Qt Day Italy, so there is tradition behind this event!

Even though it is not a Qt event, KDE Akademy is worth mentioning. Akademy is the annual world summit of KDE, one of the largest Free Software communities in the world. It is a free, non-commercial event organized by the KDE Community. This year Akademy was in Almeria Spain, in late July, 22nd to 27th. KDE has over the years brought many excellent developers to Qt, and they are definitely the biggest open source project using Qt.

Starting now is the QtCon Brasil event in São Paulo on August 18th to 20th. Taking inspiration from last years QtCon in Berlin, QtCon Brasil the first Qt community event in Brasil. The speaker list is impressive and there is an optional training day before the event. For South-American Qt developers right now is the time and place to be in São Paulo!

This year Qt Contributors’ Summit is being organised as a pre-event to Qt World Summit, and we are calling it Qt Contributors’ Days. As is tradition, the event will be run in the unconference style with the twist that topics can be suggested beforehand on the schedule wiki page. Qt Contributors’ Days gathers Qt contributors to the same location to discuss where Qt is and what direction it is heading in. The discussions are technical with the people implementing the actual features going into details of their work.

You can register to Qt Contributors’ Days at the Qt World Summit site, the nominal fee is to cover the registration expense, if it is an issue, please contact me.

The late summer and autumn are shaping up to be great times for Qt contributors!

The post 2017 for Qt Contributors appeared first on Qt Blog.

Qt Creator 4.4 RC released

We are happy to announce the release of Qt Creator 4.4 RC!

For the details on what is new in Qt Creator 4.4, please refer to the Beta blog post. As usual we have been busy with bug fixes and improvements since then, and now would be a good time for you to go get it, and provide final feedback.

Get Qt Creator 4.4 RC

The opensource version is available on the Qt download page, and you find commercially licensed packages on the Qt Account Portal. Please post issues in our bug tracker. You can also find us on IRC on #qt-creator on chat.freenode.net, and on the Qt Creator mailing list.

The post Qt Creator 4.4 RC released appeared first on Qt Blog.

Qt for Automation

Hi! As you probably know, our mission has always been to provide the frameworks and tools to help developers focus on what really matters: creating great applications.

Today, Industry 4.0 and the IoT have introduced a whole new set of challenges: There will be more connected devices, which will generate more data, that in turn will lead to even more complex software applications.

This means that the playing field will change at an exponentially accelerating pace, including the state of device infrastructure, application complexity and, last but not least, development. This results in a multi-dimensional challenge in terms of interoperability and scalability. We want to help you turn this challenge into an opportunity with our new Qt for Automation offering.

What “Automation” Means to Us

For us, Automation relates to all connected (edge) devices (clients, gateways and headless devices) and their supporting desktop applications in complex automation environments. Think everything between “smart factories”, “connected service touch points”  to “building automation”. We believe that all these segments face similar challenges from both a technical, as well as a service and business standpoint.

Why “Qt for Automation”?

Qt for Automation not only hands you additional libraries and tools but also includes domain-specific services to overcome industry-specific problems.

This first release of Qt for Automation is just the beginning. We will keep adding improvements and enhancements, which will be included in regular updates throughout the year.

Let’s have a look at the first release.

The Foundation: All the Benefits of Qt 5.9 LTS and More

With Qt for Automation you can get everything you love about Qt 5.9.x LTS, such as the Visual Keyboard, QtSerialbus, VNC,  the Qt Lite Configuration Tool, WebGL Streaming (coming with Qt 5.10) and even Boot2Qt (learn more).

The Qt Lite Configuration Tool lets you cherry-pick the features for your application as opposed to having everything included in a monolithic approach. This allows you to optimize its size, performance and start-up time on any smart device.

New: MQTT – a Future Brick for Connected Devices

Publisher-subscriber protocols have become more and more attractive to automation infrastructures. Message Queuing Telemetry Transport (MQTT) is one of the most prominent candidates for a lot of reasons. By design, it is very lightweight, fulfills high security standards, and guarantees state awareness to all infrastructure members. All those characteristics are very important, as they simplify development and make the solutions built on the protocol both safe and reliable. It has been used in sensors communicating to a broker via satellite link and in a range of home automation and small device scenarios. It is also ideal for IoT applications because of its small size, low power usage, minimized data packets, and efficient distribution of information to one or many receivers.

Our newly-developed MQTT library focuses on the client side only (not the broker) and is fully specification-compliant to protocol level 3.1 and 3.1.1 (prominently known/referred to as 4).

Our MQTT library is part of the Qt for Automation offering but is also available to the public under GPL 3 license conditions.

If you want to learn more about QtMqtt, please have a look at our blog post.

New: KNX – a Worldwide Leader in Building Automation

The KNX foundation with its KNX standard has been a long-time pioneer in standardization and operability between different vendors. It is a worldwide leader in home and building automation, with the most existing deployments . As described by KNX themselves, it is the worldwide standard for applications in home and building control, ranging from lighting and shutter control to various security systems, heating, ventilation, air conditioning, monitoring, alarming, water control, energy management, smart metering as well as household appliances, audio/video and lots more. KNX aims for the most ambitious setups and their standard is ubiquitous and widely supported by manufacturers. However, KNX’s long-standing challenge has been that it is relatively difficult to develop and deploy client applications.

With our new KNX library, we close this gap and make it easier for you to create tailor-made UIs for your smart building and integrate different functionalities (e.g. speech recognition) and technologies (e.g. BLE) in the future. We are bringing the beauty of Qt to KNX so you can switch on a light with just a few lines of code.

The KNX library is part of Qt for Automation offering but is also available to the public under GPL v3 licensing conditions.

If you want to learn more about QtKnx, please have a look at our blog post.

Create Devices, Mobile Apps and Desktop Applications on any Platform

Right from the start, we wanted to offer you something more than just the additional components we ship with Qt for Automation. We know that automation can be handled quite differently depending on the platform used, the individual solutions, the number of shipments, the development pressure and needs to solve development problems.

To address this, we decided to add more value for automation customers:

  • Capability to develop on any platform. We know our customers build devices but we know they also need to develop desktop applications and even mobile apps.
  • Automation consultancy services. We know developers regularly face pressure, but reaching out and finding help takes time. Therefore, we included industry-specific consultancy services to our offering. Just book it, you get it.

More to Come

As already stated, Qt for Automation is just the first release and there are more to come. Over time, we’ll add even more value by extending the existing libraries or tools. We have already identified topics like OPC/UA and AMQP we want to tackle next. To facilitate this development, The Qt Company and its partners have set up a dedicated and growing team :).

Join the Automation Track at QtWS 2017 in Berlin!

We are happy to announce that we’ll feature an Automation track during the QtWS 2017. Join our talks about KNX and MQTT and many more topics presented by us and our partners (e.g. CoAP).

Read and Learn More

Get in Touch with us

Yes, we are happy if you are interested in what Qt has to offer and we love talking about it. Please reach out to us.

The post Qt for Automation appeared first on Qt Blog.

Introducing QtMqtt

Recently, we talked about how we’re broadening our offering towards the automation sector. In case you missed it, you can find all relevant information here as well as read our blog post here.

One of the biggest challenges in starting an automation project is to build a suitable communication stack. MQTT has received more and more popularity over the last years for managing telemetry data (i.e. collecting data from sensors, health status of devices etc.). This is why we are now extending our portfolio to further help and simplify the development workflow.

What is MQTT

MQTT describes itself as follows:

It was designed as an extremely lightweight publish/subscribe messaging transport. It is useful for connections with remote locations where a small code footprint is required and/or network bandwidth is at a premium.”

Using a publisher-subscriber methodology puts the routing responsibility towards the server (or in this context called “message broker”), which all clients connect to. Multiple levels of service quality can be specified to guarantee message delivery.

The connection itself usually builds on top of a TCP connection. However, it can use any ordered, lossless and bi-directional communication method.

How QtMqtt Fits Into the Picture

QtMqtt is a client implementation, which can be used for creating devices to send, but also to monitor solutions for receiving and managing data. QtMqtt does not focus on the broker side.

One important item to mention is that we aim to have QtMqtt fully specification compliant compared to other solutions. This implies support for

  • Protocol level 3.1 and 3.1.1 (prominently known/referred as 4)
  • All QoS levels
  • Wildcards
  • Authentication
  • SSL connections
  • Last Will support

Let ‘s dig a bit deeper and discuss how you actually use QtMqtt in your project.

Publishing data:

QMqttClient publisher;
publisher.setHostname(“some.brokerlocation.com”);
publisher.setPort(1883);
publisher.connectToHost();

publisher.publish(“sensor_1/dataset/foo”, “values”, qosLevel);

Receiving data:
QMqttClient subscriber;
subscriber.setHostname(“some.brokerlocation.com”);
subscriber.setPort(1883);
subscriber.connectToHost();
. . .
QSharedPointer<QMqttSubscription> sub = subscriber.subscribe(“sensor_1/#”, qosLevel);
connect(sub.data(), &QMqttSubscription::messageReceived, [&](QMqttMessage msg) {
qDebug() << “New Message:” << msg.payload();
});

Security

It is crucial for any automation solution today to make sure that all communication is secure and safe. QtMqtt provides two means to achieve this:

  1. Authentication via username and password when a connection is established.
  2. Using SSL/TLS sockets as connection channel.

For the latter case, we can utilize QSslSocket as provided by Qt Network. As a convenience, QMqttClient has another member called connectToHostEncrypted() which behaves similar to QSslSocket‘s argument list.

Extending QtMqtt

While MQTT is mostly used via TCP, it isn’t hardwired to it. QtMqtt allows you to specify additional transport methods, which are based on either QIODevice or QAbstractSocket. This implies that you can create your own transport and pass it over to QMqttClient before establishing a connection.

One concrete example is to use MQTT over websockets, for which Qt provides a separate module. QWebsocket is not based on QAbstractSocket due to different means of sending and receiving data. However, the specification is very clear on how MQTT data has to be pushed via websocket (send as binary data, must fit one datagram, etc.). Hence, a convenience class can be implemented. The specific showcase can be found in the examples of the QtMqtt module.

If you found this post interesting, feel free to get in touch with us and get access to a prerelease version.

The post Introducing QtMqtt appeared first on Qt Blog.

Let There Be More Shapes!

As a follow-up to the previous post about the upcoming new Shape element, I am happy to share that the feature set is going to be bigger than previously expected, and this applies already to the upcoming 5.10 release of Qt.

The initial version of the Shape type only had support for linear gradients. The internal and external feedback indicated however that this felt rather incomplete without radial and conical gradients (especially in the light of these being fully supported by QPainter, meaning the fragment shaders doing the heavy lifting were already available, needing only minor adaptation work). The good news is that the patches for RadialGradient and ConicalGradient are now all merged. (follow the links for doc snapshots, note that these are under QtQuick.Shapes 1.0, not to be confused with the similarly named types in QtGraphicalEffects)

Let’s see these in action! It is by the way worth noting that the code snippets shown in this and the previous post can all be found at this repository.

1. Radial gradient

qmlshapedemo_radial

Shape {
    id: radGradCirc
    anchors.fill: parent
    property real r: 60

    ShapePath {
        strokeWidth: 4
        strokeColor: "red"
        fillGradient: RadialGradient {
            centerX: 100; centerY: 100; centerRadius: 100
            SequentialAnimation on focalRadius { ... }
            SequentialAnimation on focalX { ... }
            SequentialAnimation on focalY { ... }
            GradientStop { position: 0; color: "#ffffff" }
            GradientStop { position: 0.11; color: "#f9ffa0" }
            GradientStop { position: 0.13; color: "#f9ff99" }
            GradientStop { position: 0.14; color: "#f3ff86" }
            GradientStop { position: 0.49; color: "#93b353" }
            GradientStop { position: 0.87; color: "#264619" }
            GradientStop { position: 0.96; color: "#0c1306" }
            GradientStop { position: 1; color: "#000000" }
        }
        strokeStyle: ShapePath.DashLine
        dashPattern: [ 1, 4 ]

        startX: radGradCirc.width / 2 - radGradCirc.r
        startY: radGradCirc.height / 2 - radGradCirc.r
        PathArc {
            x: radGradCirc.width / 2 + radGradCirc.r
            y: radGradCirc.height / 2 + radGradCirc.r
            radiusX: radGradCirc.r; radiusY: radGradCirc.r
            useLargeArc: true
        }
        PathArc {
            x: radGradCirc.width / 2 - radGradCirc.r
            y: radGradCirc.height / 2 - radGradCirc.r
            radiusX: radGradCirc.r; radiusY: radGradCirc.r
            useLargeArc: true
        }
    }
}

2. Conical gradient

qmlshapedemo_conical

Shape {
    id: conGradCirc
    anchors.fill: parent
    property real r: 60

    ShapePath {
        strokeWidth: 4
        strokeColor: "black"
        fillGradient: ConicalGradient {
            centerX: 100; centerY: 100
            NumberAnimation on angle { ... }
            GradientStop { position: 0; color: "#00000000" }
            GradientStop { position: 0.10; color: "#ffe0cc73" }
            GradientStop { position: 0.17; color: "#ffc6a006" }
            GradientStop { position: 0.46; color: "#ff600659" }
            GradientStop { position: 0.72; color: "#ff0680ac" }
            GradientStop { position: 0.92; color: "#ffb9d9e6" }
            GradientStop { position: 1.00; color: "#00000000" }
        }

        // ... the actual shape is the same as in the previous example
    }
}

The post Let There Be More Shapes! appeared first on Qt Blog.

Qt talks at CppCon 2017

The program for CppCon 2017 is now published!

CppCon is the annual conference for the C++ community: five days packed with over 100 talks, as well as inspiring keynotes, panel discussions, hallway chats, fun evening events and much more. CppCon is a project of the Standard C++ Foundation, a not-for-profit organization whose purpose is to support the C++ software developer community and promote the understanding and use of modern, standard C++ on all compilers and platforms.

It's our pleasure to announce that Qt will be a huge presence at this year's CppCon, with a training, a keynote speech, two talks and other open content:

  • On September 23-24, KDAB's Giuseppe D'Angelo will deliver a pre-conference training on programming with QtWidgets. This course focuses entirely on QtWidgets, the set of C++ APIs offered by Qt to build cross-platform desktop applications, running on Windows, Linux and Mac.
  • On September 27, Giuseppe will also talk about how to use Qt C++ Core APIs effectively in the 2017 update of the Effective Qt session.
  • On September 29, Simon Hausmann from The Qt Company will explore what's under the hood of the Qt object model and its features (signals, slots, properties) in his Inside the Qt Object Model session.
  • Last but not least, Lars Knoll (Qt Project Chief Maintainer, CTO of The Qt Company) will deliver a keynote speech. The details have yet to be announced, but it's great to see the C++ community acknowledging the importance of the Qt framework in the C++ ecosystem.

This isn't everything -- stay tuned for more info about other Qt-related content at CppCon, including BOFs, panels and lightning talks. Also, don't forget that on September 30 and October 1, KDAB's Thomas McGuire will explain in his post-conference training how to Debug and Profile C++ Code on Linux.

You can register to CppCon here.

See you in Bellevue!

[training_callout] continue reading

The post Qt talks at CppCon 2017 appeared first on KDAB.

New in Qt 5.10: Diagnostics when breaking QML bindings

Property bindings are one of the most interesting features of the QML language. In QML, when we set a value on a property, the right hand side expression isn't evaluated just once to produce a value, like in a ordinary imperative language.

In particular, if the expression involves other properties, then the property we're setting becomes bound to the properties in the expression: whenever they change their values, then the expression is automatically evaluated again, and the target property value updated.

For instance:

[sourcecode]
import QtQuick 2.0

Rectangle {
width: 100; height: 100

// this is a binding:
color: mouseArea.containsMouse ? "red" : "blue"

MouseArea { id: mouseArea; anchors.fill: parent; hoverEnabled: true }
}
[/sourcecode]

In the snippet above, the color property of the Rectangle is the target of a binding: it is bound to the containsMouse property of the internal MouseArea. When the mouse moves inside or outside of the mouse area, its containsMouse property will change, causing the expression for color to be re-evaluated.

In layman's terms: the rectangle will be red if the mouse cursor is hovering over it, and blue otherwise.

Property bindings allow to build our UIs in a very declarative way: we don't need to write boilerplate "slots" to update our UI elements when some other property changes value. The expression that we can write on the right hand side can be as complex as we want, even involving function calls; the engine will do all the work for us, and will make the binding work as expected.

Breaking property bindings

Sounds too good to be true? Well, property bindings have a limitation: if we use an imperative assignment to set a value on a property, its binding will be lost. For instance, suppose we want the rectangle to turn green when we click over it. This is a possible implementation:

[sourcecode]
import QtQuick 2.0

Rectangle {
width: 100; height: 100

// this is still a binding
color: mouseArea.containsMouse ? "red" : "blue"

MouseArea {
id: mouseArea
anchors.fill: parent
hoverEnabled: true
onClicked: {
parent.color = "green" // oops! breaks binding
}
}
}
[/sourcecode]

In the onClicked signal handler we set the color property to green using an ordinary assignment from imperative JavaScript code. With this code, if we click on the rectangle, and then move the mouse over it and outside it, we'll see that the rectangle doesn't change color any more -- it stays green. This happens because the imperative assignment destroyed the binding, and set the color property to one specific value.

Are broken bindings a problem?

In general, the above example is 100% correct QML code, following the documented QML semantics. Therefore, one cannot claim that such code should be rejected by the QML engine or unconditionally raise warnings.

However, in my experience at KDAB, I have never encountered one single occasion when breaking a binding was intended by the developer. Broken bindings were always caused by accident (during refactorings, not realizing that the original property was bound to something, etc.), or by excessive usage of JavaScript to manage state, instead of using more declarative approaches.

On some occasions, a silent overwriting of a binding with a value did actually introduce a runtime bug, which would then stay latent, maybe for a long time. Debugging such issues could be very challenging, as it is not normally clear what the problem is when reading the QML source code -- the bug would manifest itself only when the JavaScript code containing an imperative assignment is run.

Debugging broken bindings

In order for a developer to be able to more easily track down these cases, KDAB contributed a new feature to the QML engine that will appear in Qt 5.10: the QML engine can now print debugging information whenever a binding is broken.

In order to enable the debug output you just need to enable output for the qt.qml.binding.removal logging category, for instance by exporting the QT_LOGGING_RULES environment variable:

[sourcecode]
export QT_LOGGING_RULES="qt.qml.binding.removal.info=true"
[/sourcecode]

With this variable set, the above example:

[sourcecode]
import QtQuick 2.0

Rectangle {
width: 100; height: 100

color: mouseArea.containsMouse ? "red" : "blue"

MouseArea {
id: mouseArea
anchors.fill: parent
hoverEnabled: true
onClicked: {
parent.color = "green"
}
}
}
[/sourcecode]

now prints this debug message:

[sourcecode]
qt.qml.binding.removal: Overwriting binding on QQuickRectangle::color
at file:///example.qml:13
that was initially bound at file:///example.qml:6:12
[/sourcecode]

As you can see, the message tells us which property was bound, where the binding had been established, and where the imperative statement is that breaks the binding. Pretty much everything we need to debug any issues with broken bindings!

[training_callout] continue reading

The post New in Qt 5.10: Diagnostics when breaking QML bindings appeared first on KDAB.

Qt Visual Studio Tools Version 2.1.2 Beta

After some time working on the integration with Visual Studio 2017, we would now like to make the current status of this work in progress available to users of VS 2017.

We have released a new beta of the Qt Visual Studio Tools, corresponding to version 2.1.2. It is available in the Visual Studio Marketplace and can be installed directly from within Visual Studio 2017 (through the ‘Tools > Extensions and Updates…’ menu). Alternatively, it can be downloaded from this page.

Relative to the previous 2.1.1 beta, version 2.1.2 includes some additional bug fixes:

  • Add new item with VS does not generate the moc
    (reported as QTVSADDINBUG-396)
  • Run moc’ing at every build even if there is no file changed
    (QTVSADDINBUG-410)
  • 2.1.1-beta VSIX installer fails
    (QTVSADDINBUG-460)
  • When opening a pro file with Qt 5.9, unable to create the vcxproj file
    (QTVSADDINBUG-472)

For the moment, version 2.1.2 is only available for Visual Studio 2017. There is also one noteworthy issue: Qt projects will be configured with version 8.1 of the Windows SDK, and building will result in an error if the SDK is not installed. The status of this issue and description of a workaround can be found here.

We will continue working on this and other issues and suggestions reported through bugreports.qt.io with a view to providing an official release of the Qt Visual Studio Tools, which will also be available for Visual Studio 2013 and 2015.

The post Qt Visual Studio Tools Version 2.1.2 Beta appeared first on Qt Blog.

Release 2.12.2: Firebase Realtime Listeners & Qt Creator Designer Icons

V-Play 2.12.2 adds support for Realtime Database Listeners to the Firebase Plugin, which allows your app to get notified whenever your data changes. In addition, the recently improved Qt Creator Designer now comes with icons for all V-Play types to let you distinguish the different components more easily.

V-Play 2.12.2 comes as a free update for all V-Play developers.

Firebase Realtime Database Listeners

Use the Firebase Plugin to store and sync data in realtime across all clients with the Firebase NoSQL Cloud Database.

update-2122-firebase-database-data

The Firebase Realtime Database is a cloud-hosted database. Data is stored as JSON and changes to the database are propagated to other clients in real time. This update adds new properties and signals to the FirebaseDatabase item, which you can use to add listeners for certain database entries. With the Firebase Realtime Listeners, your app is notified immediately after your data in the cloud gets changed – no matter which device, user or application changed the value.

The following example uses the FirebaseDatabase::realtimeValueKeys property and FirebaseDatabase::realtimeValueChanged() signal to keep track of a public database entry newstext:

import VPlayPlugins 1.0
import VPlayApps 1.0

App {

  FirebaseDatabase {
    realtimeValueKeys: ["public/newstext"]
    onRealtimeValueChanged: {
      if(success) {
        console.debug("Public Realtime Value '" + key + "' changed to '" + value + "'")

        // if newstext got changed -> update AppText to show news
        if(key === "newstext")
          news.text = value
      }
      else {
        console.debug("Error with message: " + value)
      }
    }
  }

  AppText {
    id: news
    text: "" // no news by default, news is loaded from database and always up-to-date
  }
}

This example already shows how powerful the new Firebase Realtime Listeners can be. As soon as the newstext entry changes in the database, all clients will get notified and replace the old news. As Firebase also supports authentication and user access rules, you could even create a real-time chat with this new feature.

 

Firebase Realtime Database vs. V-Play WebStorage

V-Play also comes with its own easy to use WebStorage, which connects to the V-Play backend hosted on Amazon servers (and also available on-premise for Enterprise Customers). It is a simple key-value store which syncs across different devices and platforms via the V-Play Game Network Backend as a Service (BaaS).

So what’s the difference between Firebase and V-Play Cloud Storage?

V-Play WebStorage has these advantages compared to FireBase:

  • All platforms: V-Play WebStorage works not only on iOS & Android, but on all supported V-Play platforms. This also includes Desktop and embedded systems.
  • No authentication required: With V-Play WebStorage, you can access per-user data without your users having to log in.
  • Late authentication: Your users can authenticate later but start saving user data before this authentication. Once they do authenticate, their data is kept and merged to the new user profile.
  • Advanced merge conflict management: With V-Play WebStorage, you can modify the default merge conflict rules that may occur if your user stores to the same key from multiple devices at the same time. In Firebase, the last write is used, whereas in V-Play a merging of the data is tried first. Additionally, you can customize the merge behavior to your requirements with the WebStorage::dataConflictStrategy property.

These are the same features like Firebase has:

  • Offline usage: You can write and read values from the storage even if the user is offline. As soon as the user has Internet Connection again, the locally cached data is synchronized with the cloud.
  • Data synchronization: If the same user is authenticated on multiple devices, a change in the data is forwarded to all connected devices in realtime. This way, the user has the same data across all devices, even across platforms.

There is one restriction with WebStorage though: user access rights. With V-Play WebStorage, there are 2 access rules: per-app and per-user data. The per-user data cannot be shared with other users, and the per-app data cannot restrict its access to certain users. You can work around this restriction by adding custom fields to your per-app data that specifies to which user the app-wide data shall be available for. However, if you have advanced requirements for user rights & data management, the Firebase Realtime Database is the better solution as you can define access rules comprehensively.

For a quick summary: if you are looking for a simple key-value store in the cloud that gets synced to multiple devices, you are better off with the V-Play WebStorage.

 

Note: If you want to build a social messaging app, a chat app, or any application where you’d like to allow your users to become friends with each other, user authentication and send messages, the V-Play Backend (using Game Network + Multiplayer functionality) is an option you can use! It features a friend system, realtime chat with push notifications, cloud storage, and more. Contact us here if you’d like to have a demo project using all these features.

 

Qt Quick Designer Icons

Since V-Play 2.12.1, it is possible to use V-Play Components with the improved Qt Quick Designer of Qt Creator 4.3. To help you get more out of the designer and quickly find the components you need, this update adds icons for all items available with the Qt Quick Designer:

update-2122-designer-icons

For a quick guide how to use the new Qt Quick Designer with V-Play, have a look at our tutorial video:

 

How to Update V-Play

Test out these new features by following these steps:

  • Open the V-Play SDK Maintenance Tool in your V-Play SDK directory.
  • Choose “Update components” and finish the update process to get V-Play 2.12.2 as described in the V-Play Update Guide.

V-Play Update in Maintenance Tool

If you haven’t installed V-Play yet, you can do so now with the latest installer from here. Now you can explore all of the new features included in V-Play 2.12.2!

 

 

More Posts Like This

How to Make Cross-Platform Mobile Apps with Qt – V-Play Apps

How to Make a Qt app

Release 2.11.0: All Monetization Plugins Now Free, Plugin Trial & Firebase Qt Plugin

Release 2_11

WeAreDevelopers Conference App – Open Source & Live Now!

WeAreDevelopers

The post Release 2.12.2: Firebase Realtime Listeners & Qt Creator Designer Icons appeared first on V-Play Engine.

QML vs. HTML5

Guest post by Stefan Larndorfer at sequality

Mobile devices have set the standard in terms of responsiveness and user-friendliness for HMIs across industries. Manufacturers of cars, medical equipment, industrial automation systems and consumer electronics now want to replicate this great user experience for their embedded devices. To find out which technology strategy we should select we set up a test where one of our developers was allocated 160 hours to create a demo application of an embedded system using Qt & QML and same number of hours to create the very equivalent application using HTML5.

Over the past year, more and more customers have been asking us at sequality if they should use HTML5 or Qt using the QML declarative UI language to develop software for embedded devices.

In order to give the most objective advice to our customers, we decided set up a test: give the same developer 160 hours to create a demo of an embedded system using Qt and 160 hours to create the demo using HTML5. These demos would show exactly how the two technologies compare – in terms of development, performance, and sustainability – when used to create the same product. The developer tasked with creating the demos was experienced with using HMTL5 and C++, but had little experience creating user interfaces using Qt and QML. The demos were created independently without any vendor input.

QML vs. HTML 5 test results

The demos showed that although the same amount of development time was spent on both versions, implementation with Qt QML delivered a more functional and complete user interface than the HTML5 version. The testing and debugging process was found to be more straightforward with Qt QML, not least because it didn’t need testing on multiple browsers. In general, the Qt QML version responded more quickly and enabled features, like keyboard and multi-touch, that were not supported by HTML5 without additional implementation.

From an end-user perspective, the Qt QML version behaved exactly as expected regardless of the browser or screen being used to view it.

This is because Qt based applications are compiled for the target, meaning that in terms of user observation, they behave exactly the same no matter which platform they run on. HTML5-based applications, on the other hand, run on the browser of the target, for example Chrome, meaning different platforms can show different behavior as the browser might use different rendering engines depending on the platform.

In terms of the sustainability of the technology, Qt QML is a mature technology that has been developed to ensure backwards compatibility. The AngularJS framework for HTML5 is relatively new, and a valid concern is whether it will be replaced by a new framework in the future. In contrast, QML is very likely to still be supported in 5 years.

Overall, Sequality found that the development of the applications was very different and one needs to carefully consider the benefits and drawbacks of each technology before deciding which one to use.

If the outcome of such an evaluation does not show major advantages of a particular technology, we would recommend Qt over HTML5. In our showcase, the Qt based application was generally faster, more responsive, and easier to implement.

Want to know more?

Download the QML vs. HTML 5 Whitepaper.

Visit us at our booth at Qt World Summit 2017.

 

About

Stefan Larndofer is the CEO and Founder of sequality software engineering. Sequality provides high-quality software engineering services, specializing in user interaction (graphical user interfaces, touch screen software, C++/Qt, embedded Linux) technology. Sequality delivers software with a great user experience, inspired by mobile devices. www.sequality.at

The post QML vs. HTML5 appeared first on Qt Blog.

Cutelyst 1.8.0 released

Cutelyst the Qt Web Framework, has another stable release, this release is mostly filled with bug fixes, the commit log is rather small.

It got fixes on Cutelyst-WSGI to properly work on Windows, QtCreator integration fixes, properly installing dll's on Windows, fix returning the right status from views (this allows you to know if for example View::Email sent the email with success).

Cutelyst is cross-platform, the code builds on CI running on Windows, OSX and Linux, but first class is still UNIX systems, as I don't use Windows, nor have a VM with development configured so I have only ensured it build fine on AppVeyor, Aurel Branzeanu provided some pull requests to improve that, if you also happen to have experience with CMake, MSVC and Windows please help me review or do other pull requests.

The release also got two API additions:

  • Context::setStash(QString, ParamsMultiMap), ParamsMultiMap also known as QMap<QString, QString> is a type used on HTTP query and body parameters, having this method avoid writing ugly code full of QVariant::fromValue()
  • Application::pathTo(QString), instead of using the QStringList version which join the strings to build a path (like the Catalyst does), this just gets the string as you would pass to a QFile, that in turn deals with platform issues.

I'm a bit busy with html-qt and also planning a rewrite of simplemail-qt to be async, so expect smaller Cutelyst releases :)

Again help is welcome (specially on Windows usage).

Get it here https://github.com/cutelyst/cutelyst/archive/v1.8.0.tar.gz

How to Add V-Play to your Qt Mobile App

If you have an existing Qt Mobile App, you can extend your Qt application with V-Play components to improve your mobile app experience. You can mix all of the V-Play and Qt components and have them combined in your project. And the best thing is, you do not need to rewrite your existing Qt application for this! Instead, you can mix the V-Play and Qt components freely in your mobile app. So if you need for example push notifications in your Qt app which uses Qt Quick Controls 2, you can use your existing code and simply add the Google Cloud Messaging (Firebase) push notification plugin by V-Play like this:

import QtQuick 2.0
import QtQuick.Controls 2.0
import VPlayPlugins 2.0

ApplicationWindow {

  GoogleCloudMessaging {
    onNotificationReceived: {
      console.debug("Received push notification: ", JSON.stringify(data))
    }
  }
}

 

This blog post is about the exact steps how you can add V-Play to your Qt Mobile App. Let’s get started.

How does V-Play Improve Qt?

The V-Play SDK for cross-platform apps and games comes with many components to make mobile development with Qt easier. V-Play extends Qt for mobile app development and offers for example:

  • Native look and feel for iOS and Android
  • Monetization with Ads and In-App Purchases
  • Analytics for User Behavior and Crash Reports
  • Push Notifications – triggered locally or by a server
  • Social Engagement with native sharing and Facebook integration
  • Gamification with Highscores, Achievements, Friend System and a Chat
  • Web Backend with cross-platform cloud data storage and syncing between multiple devices
  • Responsive Design for screen and device independence
  • Access to Native Device Features like native dialogs, the camera/image picker, phone contacts or content sharing

 

V-Play Apps Component Showcase iOS V-Play Apps Component Showcase Android

 

Note: To learn more about how V-Play improves Qt for mobile app developers and a comparison between Qt and V-Play, you can also see this page.

It is possible to use all V-Play features in your Qt Quick application, no matter if it is based on Qt Quick Controls 1 or Qt Quick Controls 2. It is even possible to use the V-Play components in your Qt Widget based app – you can contact us here if you’d like to get an example project how to do this.

All V-Play Components can be freely mixed with other QML Items in your mobile app. To make the learning curve easier, V-Play comes with many open-source demo and example projects you can use as a starting point for your own projects.

However, it is not only possible to create V-Play projects from scratch – you can even use V-Play Engine in your existing Qt Quick applications to take advantage of the included features in your Qt app. This article will guide you through all the important steps to successfully use V-Play in your Qt application:

 

Add V-Play to your existing Qt Installation

If you already installed Qt 5 on your system, we still recommend to install V-Play in parallel using our installer to avoid any Qt version compatibility issues. The V-Play and Qt installation will work side-by-side in two different directories.

If you still would like to add V-Play to your existing Qt installation, first navigate to the root SDK folder of your Qt installation and open the executable called Maintenance Tool. Then follow these steps:

1. Choose the Add or remove components option so the Settings button is shown in the bottom left corner.

qt_install_vplay_1

2. Click the Settings button and in the Settings window, click on the Repositories tab.

qt_install_vplay_2

3. Choose the bottom section User defined repositories and click the Add Repository button. Then enter the URL for your development platform in the text box. It is either:

  • https://sdk.v-play.net/2/windows
  • https://sdk.v-play.net/2/macx
  • https://sdk.v-play.net/2/linux

qt_install_vplay_3

4. Next, confirm the V-Play installation repository with OK and proceed with the Add or remove components option by pressing the Continue button.

qt_install_vplay_1

5. V-Play Engine will now show up in addition to the available Qt modules. Make sure that it is checked in the Package Manager and proceed with the MaintenanceTool to install V-Play.
qt_install_vplay_4
Note: Each V-Play version is compatible with a certain Qt version. For example, the current version 2.13.1 uses Qt 5.9.0. If you are using an older or newer version of Qt at the moment (e.g. Qt 5.8.0 or Qt 5.9.1), also select Qt 5.9.0 in this step. See the V-Play Update Guide for the currently used Qt version of V-Play.

Alternatively, you can also download the V-Play installer which comes with the supported Qt version automatically. You can install V-Play side-by-side with Qt in a different directory. They will both work independently from each other then.

6. Choose Done when the installation has finished to close the installer.

qt_install_vplay_5

7. You can now open Qt Creator and log-in to your V-Play Account on the new welcome page, which was added by installing V-Play.

qt_install_vplay_6

8. If you do not have a V-Play Account yet, you can create a new account on the V-Play Website. Open the downloads page and choose Download to open the sign-up popup, which will guide you through the registration. As you already added V-Play to your Qt installation, you can skip the actual download after you’ve completed the sign-up.

qt_install_vplay_7

After you’ve successfully installed the V-Play SDK and logged into your V-Play account with Qt Creator, you can start using V-Play in your projects.

Integrate V-Play in your Qt Quick Project

To correctly link and initialize the V-Play components, some additional steps are required for each project that uses V-Play. First, open your Qt Quick Project with Qt Creator. You can then follow these steps to add V-Play:

1. Modify your .pro file configuration to link the V-Play SDK to your project

CONFIG += v-play

2. Open the main.cpp of your project and initialize V-Play

#include <QGuiApplication>
#include <QQmlApplicationEngine>
#include <VPApplication> // 1 - include VPApplication

int main(int argc, char *argv[])
{
    QGuiApplication app(argc, argv);
    VPApplication vplay; // 2 - create VPApplication instance

    QQmlApplicationEngine engine;
    vplay.initialize(&engine); // 3 - initialize V-Play

    engine.load(QUrl(QStringLiteral("qrc:/main.qml")));
    return app.exec();
}

3. In your main.qml, use V-Play GameWindow or App as your main ApplicationWindow (this is required for license validation and other checks)

import VPlay 2.0

GameWindow {
  licenseKey: ""
  // ...
}

Alternatively, you can also add a GameWindowItem as a child to your main window instead:

import VPlay 2.0

ApplicationWindow {
    // ...
    GameWindowItem {
      licenseKey: ""
    }
}

4. Add a new file qml/config.json to your project resources, and configure your correct application id and version:

{
    "title": "V-Play App",
    "identifier": "net.vplay.demoapp",
    "orientation": "auto",
    "versioncode": 1,
    "versionname": "1",
    "stage": "test"
}

5. When activating V-Play with a valid license key, the identifier and version of the config.json needs to match the actual app id and version of your mobile app. For Android apps, the identifier and version are configured in the AndroidManifest.xml:

<manifest package="net.vplay.demoapp" android:versionCode="1" … >

If your application does not yet have an Android configuration, you can choose the Projects tab in Qt Creator, select the Android Kit, expand the Build Android APK section and choose Create Templates. This will create a default configuration within a new android subfolder of your project, which also includes the manifest.

6. For iOS, you can set the identifier and version in the Info.plist configuration of your app:

   <key>CFBundleIdentifier</key>
   <string>net.vplay.demoapp</string>
   <key>CFBundleVersion</key>
   <string>1</string>

This configuration file is created by qmake when building for iOS. You can add the following qmake entry to your *.pro configuration to keep and use a custom iOS configuration for your project:

ios {
   QMAKE_INFO_PLIST = ios/Info.plist
}

Make sure to have the correct setting for all three configuration files. If everything looks good, you are ready to use V-Play in your QML application.

You can download this example from GitHub as a reference project too:

Use V-Play Components in your QML Code

Using V-Play in the QML files of your Qt Quick application is easy. All V-Play types are available as QML components and can be used just like any other Item in QML. Mixing V-Play types with Qt components like Qt Quick Controls 2 is also possible.

For example, if you like to add add an easy-to-use local storage to your application, simply add the V-Play import and use the Storage component of V-Play:

import VPlay 2.0

Storage {
  id: localStorage
  property int counter

  onCounterChanged: localStorage.setValue("counter", counter)
  Component.onCompleted: counter = localStorage.getValue("counter") || 0
}

This example saves a counter property in a local SQLite database. The code loads the previous counter value at app start and automatically stores the counter every time it is changed in the app.

It is even possible to use the WebStorage item instead, which utilizes the V-Play Game Network service to synchronize the stored data across devices of the same user:

import VPlay 2.0

VPlayGameNetwork {
  id: gameNetwork
  gameId: <your-vplay-gamenetwork-id>
  secret: "<your-vplay-gameetwork-secret>"
}

WebStorage {
  id: localStorage

  property int counter

  onCounterChanged: localStorage.setValue("counter", counter)
  Component.onCompleted: counter = localStorage.getValue("counter") || 0
}

This is all the code required to include a simple cloud-based data storage.

Other V-Play Components offer the same ease-of-use, for an overview of all available types and features, please have a look at the online documentation of V-Play.

Access Native Device Features in your Qt App

Another big advantage of V-Play is the possibility to use native device features like the camera or confirmation and input dialogs – the NativeUtils component is all you need.

This example shares a custom text and url with the native share dialog on Android and iOS:

import VPlayApps 1.0

App {
AppButton {
  text: "Share!"
  onClicked: nativeUtils.share("V-Play is awesome!", "https://v-play.net")
}
}

Taking a photo with the camera and displaying the shot afterwards is just as simple:

// open camera on button click
AppButton {
  text: "Take Photo"
  onClicked: nativeUtils.displayCameraPicker("Take Photo")
}

// show image after photo was taken
Connections {
  target: nativeUtils
  onCameraPickerFinished: {
    if(accepted) {
      image.source = path
    }
  }
}

AppImage {
  id: image
  anchors.fill: parent
  fillMode: AppImage.PreserveAspectFit
  autoTransform: true
}

When working with dialogs, the V-Play Apps type NativeDialog is also available and offers a more convenient usage to trigger a dialog and handle the response:

AppButton {
   text: "Confirm Dialog"
   onClicked: NativeDialog.confirm("Please Confirm", "Confirm this action?", function(ok) {
     if(ok) {
       // confirmed
     }
     else {
       // not confirmed
     }
   })
 }

Integrate Third-party Services in your Qt Mobile App

V-Play Plugins allow to integrate leading third-party services for ads, analytics, push notifications and more. All native plugins are available to use in your Qt Quick application and offer a convenient way to fast-forward app and game development for iOS and Android.

Since V-Play 2.11.0 it is even possible to fully use V-Play including all monetization plugins with the free Personal Plan of V-Play. Adding services like Google AdMob, Chartboost or Soomla In-App Purchases has never been easier.

plugindemo-admob-android_opt

a. Native Plugin Integration in Qt

With a single import and QML Item, you can for example show an AdMob Banner in your app:

import VPlayPlugins 1.0

AdMobBanner {
  adUnitId: "<your-admob-banner-adUnitId>"
  banner: AdMobBanner.Smart
  anchors.bottom: parent.bottom
}

To actually use the plugin with this simple approach on iOS or Android, a few more steps are required. For example, linking the Android Libraries for Google AdMob with your application requires the following gradle dependency:

allprojects {
  repositories {
      maven { url 'https://sdk.v-play.net/maven/' } // add V-Play repository
  }
}

dependencies {
  compile 'net.vplay.plugins:plugin-admob:2.+' // import admob plugin libraries
}

Just have a look at the plugin documentation of your desired plugin and view the integration steps for more information.

To also prepare the above example for iOS, first copy the GoogleMobileAds.framework from the ios subfolder of the V-Play Plugin Demo on GitHub to a sub-folder called ios within your project. Then add this setting to the qmake configuration in your *.pro file:

ios {
  VPLAY_PLUGINS += admob
}

A short extension to the Project-Info.plist configuration of your iOS app completes the iOS integration steps for using AdMob:

<key>NSAppTransportSecurity</key>
<dict>
    <key>NSAllowsArbitraryLoads</key>
    <true/>
    <key>NSAllowsArbitraryLoadsForMedia</key>
    <true/>
    <key>NSAllowsArbitraryLoadsInWebContent</key>
    <true/>
</dict>

b. Plugin Activation

Monetization plugins are usable with the free version of V-Play. However, without having a valid V-Play License Key set, only trial-modes are available for all plugins. To be able to set the GameWindowItem::licenseKey with a valid key, let’s first create a new key for the app.

After signing in to your V-Play account, you can create as many keys as you want in the License Key Creation section of the Developers Dashboard. This is how it works:

1. Choose the plugins you want to include in your license key:
plugin-activation-license-1

2. Click on “Generate License Key” and set the app identifier & version code of your application. You can see that the AdMob plugin was enabled in this license key:
plugin-activation-license-2

3. Copy the generated licenseKey to your GameWindowItem, GameWindow, or App component.
plugin-activation-license-3

4. You can now fully use the AdMob plugin on both iOS and Android!

This approach is the same for every plugin and each license key you create allows to activate all the plugins you need. If you encounter any issues when using V-Play in your Qt applications, don’t hesitate to contact us at support@v-play.net or in the support forums.

The full example of this guide also available on GitHub:

 

 

More Posts Like This

 

Release 2.12.1: Visual Editor & Qt Quick Designer Improvements
V-Play Update 2.12.1: Qt Quick Designer Improvements

How to Make Cross-Platform Mobile Apps with Qt – V-Play Apps

How to Make a Qt app

Release 2.11.0: All Monetization Plugins Now Free, Plugin Trial & Firebase Qt Plugin

Release 2_11

WeAreDevelopers Conference App – Open Source & Live Now!

WeAreDevelopers

The post How to Add V-Play to your Qt Mobile App appeared first on V-Play Engine.

clazy 1.2 released

In the previous episode we presented how to uncover 32 Qt best practices at compile time with clazy. Today it's time to show 5 more and other new goodies present in the freshly released clazy v1.2.

New checks

1. connect-not-normalized

Warns when the content of SIGNAL(), SLOT(), Q_ARG() and Q_RETURN_ARG() is not normalized. Using normalized signatures allows to avoid unneeded memory allocations.

Example:

[code lang="cpp"]
// warning: Signature is not normalized. Use void mySlot(int) instead of void mySlot(const int) [-Wclazy-connect-not-normalized]
o.connect(&o, SIGNAL(mySignal(int, int)),
&o, SLOT(void mySlot(const int)));
[/code]

See QMetaObject::normalizedSignature() for more information.

2. returning-data-from-temporary

Warns when returning the data from a QByteArray that will soon be destroyed. Accessing such data usually results in a crash. For example:

[code lang="cpp"]
QByteArray b = ...;
return b.data();
[/code]

[code lang="cpp"]
return funcReturningByteArray().data();
[/code]

[code lang="cpp"]
return funcReturningByteArray().constData();
[/code]

[code lang="cpp"]
const char * getFoo()
{
QByteArray b = ...;
return b; // QByteArray can implicitly cast to char*
}
[/code]

[code lang="cpp"]
const char *c1 = getByteArray();
const char *c2 = str.toUtf8().data();
[/code]

3. install-event-filter

Warns on potential misuse of QObject::installEventFilter().
To install an event filter on obj1 you should call obj1->installEventFilter(this), but sometimes you'll write installEventFilter(obj1) by mistake, which compiles fine.

4. qcolor-from-literal

Warns when a QColor is being constructed from a string literal such as "#RRGGBB".
This is less performant than calling the ctor that takes ints, since it creates temporary QStrings.

Example:

[code lang="cpp"]
QColor c("#000000"); // Use QColor c(0, 0, 0) instead
c.setNamedColor("#001122"); // Use c = QColor(0, 0x11, 0x22) instead
[/code]

5. strict-iterators

Warns when iterator objects are implicitly cast to const_iterator.
This is mostly equivalent to passing -DQT_STRICT_ITERATORS to the compiler, except that it also works for QString. This prevents detachments but also caches subtle bugs such as:

[code lang="cpp"]
QHash<int, int> wrong;
if (wrong.find(1) == wrong.cend()) {
qDebug() << "Not found";
} else {
// find() detached the container before cend() was called, so it prints "Found"
qDebug() << "Found";
}

QHash<int, int> right;
if (right.constFind(1) == right.cend()) {
// Prints "Not Found". This is correct now !
qDebug() << "Not found";
} else {
qDebug() << "Found";
}
[/code]

New features

1. clazy-standalone

Many people asked for clang-tidy support. This can't be done due to clang-tidy not supporting plugins yet. Thus, clazy-standalone was born. It works in a similar way as clang-tidy, by operating on a json compilation database instead of being loaded as a compiler plugin. It can be invoked as:

[code lang="bash"] clazy-standalone -checks=level1 -p compile_commands.json myfile.cpp [/code]

2. ASTMatchers

If you want to contribute a new check to clazy you can now use the AST Matchers API instead of the low level AST way. AST Matchers are gaining popularity and used in many clang tooling already.

3. Pre-built Windows binaries

Since it's an hassle to build LLVM on your own on Windows, we've made a pre-built ready to use
clazy v1.2 package.

The End

That's all folks. You can get clazy from https://phabricator.kde.org/source/clazy/. Be sure to check the README.md file, it should have answers to most (clazy related) questions.

Please try it and report bugs! continue reading

The post clazy 1.2 released appeared first on KDAB.