Quantcast
Channel: Planet Qt
Viewing all 15410 articles
Browse latest View live

Sandro S. Andrade: meg@akademy2017

$
0
0

Hi there,

It's been a while since my last post over here. After being drained with a lot of work on the very first edition of QtCon Brasil, we all had to take some rest to recharge our batteries and get ready for some new crazinesses.

This post is a short summary of the talk I presented at Akademy 2017, in the quite sunny Almería in Spain. Akademy is always a fascinating experience and it's actually like being at home, meeting old friends and getting recurrently astonished by all awesomeness coming out of KDE community :).

My talk was about architecting Qt mobile applications (slides here | video here). The talk started with a brief report on our Qt mobile development experiences at IFBa in the last two years and then I explained how we've been using lean QML-based architectures and code generators to leverage the productivity and provide flexible and reusable solutions for Qt mobile applications.

Our approach ‒ named Meg‒ is defined by two major components: a lean dynamic QML-based architecture for Qt mobile applications and a code generator for enabling the creation of modular RESTful servers and Qt mobile applications. Meg provide a Ruby-based CLI, built on top of Thor CLI framework, with templates specified in ERB (Embedded RuBy). We also designed a nice architecture for the generator itself, so that new templates can be defined as new Thor modules. The framework that implements the lean architecture we designed for Qt mobile applications already provides a JSONListModel QML object, making it easier to implement RESTful Qt clients.

The following templates are currently available:

  • Sinatra RESTful server with modular architecture (sinatra-server)
  • Ruby Sinatra RESTful service plug-in (sinatra-service-plugin)
  • Simple Qt mobile app with plugin-based architecture (simple-app)
  • Qt mobile RESTful app with plugin-based architecture (restful-app)
  • Qt mobile RESTful client plug-in (restful-client-plugin)

You're welcome to try it :) Here is what you need to do:

* git clone https://github.com/sandroandrade/meg.git
* install ruby
* run ‘gem install bundler’
* Run ‘bundle install’
* Meg CLI is available in ‘./bin/meg’

Creating a simple plugin-based QML application

So, these are the steps to create a simple plugin-based QML application using Meg:

1. Create a new project using simple-app as project type (template):
./bin/meg new SimpleApp -t simple-app
2. Create a new plugin, for example, to display students information:
./bin/meg generate plugin students -t basic-plugin -a simpleapp/
3. Create another plugin, for example, to display teachers information:
./bin/meg generate plugin teachers -t basic-plugin -a simpleapp/

In step 1, we create a new project in the simpleapp directory, using the basic-plugin template (-t option). In steps 2 and 3, we create two plugins (students and teachers), using the basic-plugin template and install them at simpleapp directory. After that, your application is available at simpleapp directory and can be built by a normal qmake/make run.

Here is what you get out of those steps:
simpleapp

Creating a Sinatra-based RESTful server

Besides automating the creation of Qt-based mobile clients, Meg also provides some templates for generating RESTful servers based on Sinatra Ruby microframework. As in the client-side, we also designed a plugin-based architecture for the RESTful server, where new services are provided by separate modules. Here are the steps to create a new RESTful server:

1. Create the server project:
./bin/meg new myserver -t sinatra-server
2. Create a plugin for handling CRUD operations for an application for visualizing a conference program:
./bin/meg generate plugin Conference -t sinatra-service-plugin -a myserver/ acronym:string name:string city:string country:string venue:string start_date:datetime end_date:datetime
3. Create a similar plugin for handling CRUD operations for handling speakers:
./bin/meg generate plugin Speaker -t sinatra-service-plugin -a myserver/ name:string affiliation:string shortbio:string

To run the server you first need to setup the database:

$ cd myserver
$ rake db:migrate

And populate some data:

$ sqlite3 db/development.sqlite3
insert into conferences values (1, 'QtCon-BR', 'QtCon Brasil', 'São Paulo', 'Brasil', 'Espaco Fit', '2017-08-18 09:00:00', '2017-08-20 18:00:00');
insert into conferences values (2, 'Akademy', 'Akademy', 'Berlin', 'Germany', 'BCC', '2017-03-01 09:00:00', '2017-03-03 18:00:00');
insert into conferences values (3, 'Conf.KDE.in', 'Conf.KDE.in', 'Guwahati', 'India', 'IIT', '2017-03-10 09:00:00', '2017-03-12 18:00:00');
insert into speakers values (1, 'Our beloved Konqi', 'KDE', 'Konqi is awesome');
insert into speakers values (2, 'Dirk Gently', 'Adams', 'He is a holistic detective');

Now, you can start the server:

$ ruby myserver.rb

Creating a Qt-based RESTful client

Creating a Qt-based RESTful client for our server is also quite simple:

$ ./bin/meg new MyApp -t restful-app
$ ./bin/meg generate plugin conferences -t restful-client-plugin -a myapp -i name -c university acronym:string name:string city:string venue:string start_date:datetime end_date:datetime
$ ./bin/meg generate plugin speakers -t restful-client-plugin -a myapp -i name -c microphone name:string affiliation:string shortbio:string

Such commands create a new Qt mobile project, using the restul-app template. Then, two RESTful client plugins for the aforementioned services are created and installed in the project directory. You can now build your Qt mobile client and, once started the server, this is what you get out from it:

restfullapp

So, that's all folks! We hope this can improve somehow the development workflow and of RESTful-based Qt mobile applications. This is a one-year project being carried out at IFBa by myself and Eliakin Costa. Hopefully, we'll get back with some news soon.

See you!


The Qt Company Blog: Qt WebGL: Cinematic Experience

$
0
0

Following the previous blog posts related to the Qt WebGL plug-in development updates, we have some features to show.

As a quick recap: Qt WebGL QPA plug-in is a new platform plug-in which will allow your Qt Quick applications to be streamed and ran directly into the browser using streaming of OpenGL calls and rendered in the client using WebGL. For more info, check the related posts below.

After some months of bug-fixing and other improvements, we managed to accomplish some cool stuff. Take a look at one of our good old demos – Qt Cinematic Experience, running remotely on a TV Web Browser:

In the video, you can see the demo running remotely on the built-in web browser of a usual TV. For the interaction with the application, I’m using the ‘extremely fast’ TV remote which is interpreted as a mouse device. This shows that you can use the WebGL streaming plug-in if your application is targeting a smart-device with a browser to try your applications without creating and deploying the application, this can save a lot of development time.

Remember, you’ll be able to test the plug-in in the upcoming Qt 5.10 release. If you find any bug don’t hesitate to report it.

NOTE: If your application is using Text.NativeRendering and your text is not displayed properly, try removing this option.

The post Qt WebGL: Cinematic Experience appeared first on Qt Blog.

The Qt Company Blog: Qt for Device Creation 5.10 Emulator update

$
0
0

controlwindow

The new Emulator 3.0 will address the need to simulate devices with multiple screens. For example, these are present in the dashboards in modern cars.

Multi-screen support

Modern cars have multiple screens on their dashboard. To ease development of applications utilizing multiple screen the emulator has a new multi-screen feature which allows you to emulate devices having multiple screens. In the mockup file, which is now QML based you can declare several displays.

Applications can use one or more screens at the same time.
For every screen your application has to create a separate QQuickView.
for (auto screen : QGuiApplication::screens()) {
auto quickView = new QQuickView();
quickView->setScreen(screen);
quickView->setSource(QUrl(""));
quickView->showFullScreen();
}

Multi-point touch support

Touch and multi-point touch input is supported on all screens. Also the way it works is easier to use.

In multi point touch mode you start by clicking on the screen to add as many touch points as needed.

Starting a left click drag on one of the points will perform a swipe gesture using all of the points while a right click drag will perform a pinch gesture around the average center of all points.

emulator-multiscreen

Plugin Interface

The API for plugins has been simplified. Some parts of the emulator itself are also shipped as plugins as well.
This allows you to provide your own controls in the UI or handle custom communications with a client running inside
the virtual machine.

Mockup is QML

The mockup design done in QML and allows to add sophisticated custom controls more easily. Components like screens and terminals can be handles like regular QML components.

Product information

The Emulator 3.0 is part of Qt for Device Creation within Qt 5.10.

The post Qt for Device Creation 5.10 Emulator update appeared first on Qt Blog.

KDAB on Qt: KDAB, MyScript and Qt Company to create new, non-distractive input method for the Automotive Industry

$
0
0

https://youtu.be/Su2Xxx_fEmo?rel=0&showinfo=0

KDAB will be partnering with MyScript and The Qt Company to incorporate MyScript’s handwriting input technology into the Qt Automotive Suite. This integration will enable multimodal input capabilities using either the existing Qt Virtual Keyboard or a new handwriting input panel powered by MyScript technology.

KDAB's Jan Arne Petersen  demonstrated some of the potential of this integration in his "Using Virtual Keyboards on Qt Embedded Devices" presentation at Qt World Summit 2017.

Volker Krause, Director Automotive at KDAB, said, “MyScript technology offers a highly intuitive user interface and is a great complement to the Qt Automotive framework. We are very excited to partner with MyScript and bring the advantages of multimodal functionality to the automotive cockpit. We look forward to a successful business relationship for the benefit of our mutual partners and customers.”

Read the recent press release...

also on Myscript's website...continue reading

The post KDAB, MyScript and Qt Company to create new, non-distractive input method for the Automotive Industry appeared first on KDAB.

The Qt Company Blog: CPU usage improvements in Qt 3D

$
0
0

Many improvements have been made to Qt 3D since the release of Qt 5.6, our previous long-term-support (LTS) release. Engineers from KDAB and The Qt Company have been working hard to bring new features to Qt 5.9 LTS, many of which are listed in the What’s new in Qt 3D with Qt 5.9 blog post by Sean Harmer from KDAB. While more features are still on the way (such as a Vulkan backend), the focus in the latest releases has shifted towards performance and stability. The performance has in fact improved greatly since Qt 5.6, especially for complex scenes and scenes with large frame graphs.

Scenes with many viewports typically result in large frame graphs because each viewport corresponds to a leaf node. If you are not familiar with the frame graph concept in Qt 3D and how powerful it is, you should check out Paul Lemire’s blog post at kdab.com. The screenshot below is from one of our internal benchmarks; a fairly simple (and colorful) scene with 28 viewports:

Qt 3D benchmark with many viewports

The CPU usage in this benchmark has gone significantly down from Qt 5.6.2 to Qt 5.9.2, and the Qt Company is working together with the engineers in KDAB on a series of changes that we expect will make the CPU usage drop even further in Qt 5.11:

viewport-benchmark-results

Many of the performance improvements have been driven forward by the port of the Qt 3D Studio runtime to be based on Qt 3D. Although the runtime is planned for a release next year, we are already now adding performance improvements to the current Qt 5.9.x LTS series. Here are some benchmark results from our internal Qt3D Studio examples:

3dstudio-benchmark-results

Performance improvements are added in many parts of Qt 3D. We have for instance also added support for efficient file formats, such as glTF2. In this post, we will go into details about some of the changes we are making to reduce the CPU usage, while in a later post, we will discuss reductions in memory consumption.

Improving the job dependency solver

One of the performance improvements we have made was to the Qt 3D job dependency solver. Qt 3D divides work that needs to be done each frame into separate, smaller jobs that can be run in parallel. The jobs are part of the flexible backend/frontend architecture of Qt 3D, which separates the frontend on the main thread from the backend, which consists of aspects that perform the rendering, input handling, and animation (more on this in the Qt 3D Overview docs).

The backend runs jobs from the different aspects on a thread pool, and each job can define dependencies on other jobs that should run before it. These dependencies need to be resolved efficiently, because the jobs often change from one frame to another. While this is simple when the number of jobs is small, it becomes increasingly time-consuming for complex scenes with large frame graphs.

By profiling our examples with Callgrind, we found performance bottlenecks in certain parts of the job dependency solver. Specifically, a large QVector of all dependencies would be resized whenever jobs were finished and corresponding dependencies could be removed from the list. This drastically reduced the performance.

We started working on a solution where we would get rid of the QVector altogether and store two lists on the jobs instead: One list of who the job has dependencies on and one list of who depends on it.

class AspectTaskRunnable {
    // ... other definitions
    QVector m_dependencies;
    QVector m_dependers;
};

With this solution, when a job finished, it could go through its list of m_dependers and remove itself from the depender’s list of m_dependencies. If their list was now empty, that job could also be started. However, we now had many small QVectors that were resized all the time. Although better than resizing a big QVector, it was still not optimal.

Finally, we realized that because the dependencies cannot change while jobs are running, there was no need to track both who depends on a job and who the job is dependent on. For each job, it is enough to know which jobs depend on it, and only the number of jobs it is dependent on.

class AspectTaskRunnable {
    // ... other definitions
    int m_dependencyCount = 0;
    QVector m_dependers;
};

Whenever a job is finished, we go through the list of jobs depending on it, and subtract their dependency count by one. The latter code looks something like this (shamelessly simplified for readability):

void QThreadPooler::taskFinished(AspectTaskRunnable *job)
{
    const auto &dependers = job->m_dependers;
    for (auto &depender : dependers) {
        depender->m_dependencyCount--;
        if (depender->m_dependencyCount == 0) {
            m_threadPool.start(depender);
        }
    }
}

By implementing this change, the job dependency solver became an insignificant contributor to the CPU usage, and we could start focusing on other bottlenecks.

Improving the performance of QThreadPool

Other parts of Qt are also benefiting from optimization opportunities found in our benchmarks. For instance, Qt 3D uses QThreadPool from Qt Core to automatically manage the jobs and allocate them to different threads. However, similarly to the previous case, QThreadPool used to store jobs in a QVector which would be resized whenever a job was finished. This is not a big issue for use cases with few jobs, but suddenly became a bottleneck for complex Qt 3D scenes with a large number of jobs.

We decided to change the implementation in QThreadPool to use larger “queue pages” and put pointers to these pages in a QVector. In each page, we keep track of the index of the first job in the queue and the index of the last job in the queue:

class QueuePage {
    enum {
        MaxPageSize = 256;
    }; 

    // ... helper functions, etc.

    int m_firstIndex = 0;
    int m_lastIndex = -1;
    QRunnable *m_entries[MaxPageSize];
};

Now, all we have to do is increment the first index whenever a job is finished and increment the last index when a job is added. If there is no more room in the page, we allocate a new one. It’s a simple and low-level implementation, but it’s also way more efficient.

Caching the results of specific jobs

Next, we found that certain jobs stood out as very CPU-demanding. Some of these jobs, such as the QMaterialParameterGathererJob, were doing a lot of work each frame even though the results from previous frames were the same. This was a clear opportunity for caching the results to improve the performance. First, let us have a look at what QMaterialParameterGathererJob does.

In Qt 3D, you can override the values of every parameter defined in a QRenderPass by setting it on the QTechnique, QEffect or QMaterial which is using that render pass. Each parameter is in turn used to define a uniform value in the final shader program. This code shows a QML example where the parameter "color" is set on all levels:

Material {
    parameters: [
        Parameter { name: "color"; value: "red"}
    ]
    effect: Effect {
        parameters: [
            Parameter { name: "color"; value: "blue"}
        ]
        techniques: Technique {
              // ... graphics API filter, filter keys, etc.

              parameters: [
                  Parameter { name: "color"; value: "green"}
              ]
              renderPasses: RenderPass {
                  parameters: [
                      Parameter { name: "color"; value: "purple"}
                  ]
                  shaderProgram: ShaderProgram {
                      // vertex shader code, etc.

                      fragmentShaderCode: "
                          #version 130
                          uniform vec4 color;
                          out vec4 fragColor;
                          void main() {
                              fragColor = color;
                          }
                      "
                  }
              }
          }
    }
}

To figure out the final value of a parameter used in the shader program, QMaterialParameterGathererJob goes through all the materials in a scene and finds the corresponding effects, techniques, and render passes. Then, by prioritizing parameters set in QMaterial over QEffect, QTechnique, and QRenderPass, we determine the final value of the parameter.
In this case, the value is "red", because the QMaterial parameters have the highest priority.

Gathering all parameters is quite time-consuming in large scenes with many materials, and showed up as a bottleneck for some of our Qt 3D Studio examples. We therefore decided to cache the parameter values found by the QMaterialParameterGathererJob, but quickly understood that the cache would always be invalidated if the values changed every frame. This is a common case, especially if parameters are animated. Instead, we decided to cache pointers to QParameter objects rather than their values. The values are then stored outside of the cache, and are fetched only when needed. Caching the results resulted in a huge performance boost in scenes with many parameters, as we only had to run the job when there are larger changes in the scene, such as when materials are added.

We have worked with many cases like this, where we have taken some of our larger examples, profiled them, identified bottlenecks in specific jobs, and worked to find ways to improve the performance or cache the results. Thankfully, the job-based system in Qt 3D makes it easy to optimize or cache specific jobs independently, so you can expect more improvements like this to land in the upcoming Qt 3D releases.

The post CPU usage improvements in Qt 3D appeared first on Qt Blog.

The Qt Company Blog: Qt 5.10 brings the new Qt Virtual Keyboard 2.3

$
0
0

The Qt Virtual Keyboard provides you an input framework and reference keyboard frontend for Qt 5 on Linux Desktop/X11, Windows Desktop, and Boot2Qt– embedded target platforms. In addition to a virtual keyboard, the module also offers versatile handwriting recognition with support for multiple different languages.

You can choose among customizable keyboard layouts and styles with dynamic switching, with support for different character sets (Latin, Simplified/Traditional Chinese, Hindi, Japanese, Arabic, Korean, and others) and support for ever increasing number of languages, with possibility to easily extend the language support, preserving the cross-platform functionality.

Some cool features of earlier releases:

  • Left-to-right and right-to-left input.
  • Predictive text input with word selection.
  • Character preview and alternative character view.
  • Automatic capitalization and space insertion.
  • Scalability to different resolutions.
  • Hardware key support for 2-way and 5-way navigation.
  • Audio feedback
  • Handwriting support, with gestures for full screen input.

New features!

With Qt 5.10 comes a new release of Qt Virtual Keyboard: 2.3. With this release we have introduced many new layouts:

  • Bulgarian
  • Czech
  • Croatian
  • Dutch
  • Greek
  • Estonian
  • Hebrew
  • Hungarian
  • Serbian

All languages provided by the Qt Virtual Keyboard will as well be supported with the new handwriting solution, including most Latin languages, also including Cyrillic, Arabic, Chinese, Japanese and Korean.

Here’s a GIF demonstrating the Korean handwriting support and my first attempts at writing Korean:

Korean handwriting support in Qt Virtual Keyboard

Korean handwriting support in Qt Virtual Keyboard

The Japanese keyboard input received several fixes (it no longer crashes when pressing the space after entering a smiley; there were a bunch of small fixes and optimizations).
We also added an InputModeKey to switch between different input modes (e.g. various Asian layouts, numeric, Latin).

Qt Virtual Keyboard is available under GPLv3 open source license and the commercial license from The Qt Company. There is currently choice to use open-source engine for handwriting recognition and word prediction, or a commercial T9 Write solution form Nuance. We are also working with other partners to extend the support for other commercial engines in lated releases of Qt. More info about the related upcoming partnerships is available here.

The new Qt Virtual Keyboard 2.3 is included into the upcoming Qt 5.10 release. Stay tuned to hear more about all the great new additions of Qt 5.10.

The post Qt 5.10 brings the new Qt Virtual Keyboard 2.3 appeared first on Qt Blog.

Lorn Potter: Qt for WebAssembly update

$
0
0

The project Qt 5 emscripten that Intopalo (who are doing tons of amazing stuff with some awesome talent) started as research for a client, has moved git repos. The new main git repo has been moved to a branch in Qt proper! and a new name - Qt for WebAssembly.

git://code.qt.io/qt/qtbase.git in the 'wip/webassembly' branch, and can be downloaded here:
git clone -b wip/webassembly git://code.qt.io/qt/qtbase.git

which is also here at github:
https://github.com/qt/qtbase/tree/wip/webassembly

Along with the move comes expanded requirements, like targeting non QtWidgets based apps, including QtDeclarative.

As well, it now builds only for wasm and does not bother with the asmjs fallback, This means your web browser will need to specifically support wasm. Pure wasm builds in emscripten have performance optimizations that do not happen when also building the asmjs fallback.

That said....

*NOTE* Qt for WebAssembly is still very alpha and buggy! Some of which I will cover in the next blog post.

I have managed to conjole Qt Creator to use the emscripten built Qt for apps. Here are the steps to do so, if you are so inclined.

Build Qt for web assembly.

1) Download and build emsdk (you may also try to pre built binary version)

git the emsdk source repo:
git clone https://github.com/juj/emsdk.git
(to update: git pull; ./emsdk update-tags )

Follow these instructions to build emsdk:
http://kripken.github.io/emscripten-site/docs/getting_started/downloads.html#installation-instructions

I usually use 'incoming' instead of 'latest', as it has more recent features.

/path/to/emsdk install sdk-master-64bit binaryen-master-64bit

2) Download Qt for emsdk

git clone -b wip/webassembly https://code.qt.io/qt/qtbase.git

3) Build Qt

source /path/to/emsdk/emsdk_env.sh

$QT_DIR/configure -xplatform emscripten -confirm-license -opensource -nomake tests -nomake examples -developer-build -no-dbus -no-headersclean -release -no-thread  -no-feature-networkinterface

(non developer builds should work too)

4) Add emscripten compiler to Creator

  • Tools->Options->Build & Run -> Compilers->Add->Custom
  • add emcc as C, and emc++ as C++
  • 'emscripten' as Qt mkspecs.
  • ABI: x86, linux (or whatever platform you build on), unknown, elf, 64bit

5) Add emscripten built Qt

  • Tools->Options->Build & Run ->Qt Versions->Add
    • add the qmake from your emscripten Qt build.
6) Add emscripten kit

  • Tools->Options->Build & Run ->Kits->Add
    • add emcc and emc++ as Compilers
    • If you use cmake, you can also add to CMake configuration:
      • CMAKE_TOOLCHAIN_FILE=/path/to/emsdk/emscripten/incoming/cmake/Modules/Platform/Emscripten.cmake
7) Build your app
  • Use 'release' mode build, as 'debug' will result in a runtime error: "failed to asynchronously prepare wasm: CompileError: wasm validation error: at offset 14762: too many functions"
8) Run your app

  • add custom executable: Projects->(qt5-wasm) Run
    • specify /path/to/emsdk/emscripten/incoming/emrun
      • arguments: .html
        • I also use --browser firefox (I use nightly)
Hopefully some things will actually work! This is all still in the development phase. Your kilometerage will vary. 

Good luck! You can join the fun, we are in #qt-webassembly at https://qtmob.slack.com and on freenode.


The Qt Company Blog: Security advisory about Qt for Android

$
0
0

Two vulnerabilities have been identified in Qt for Android which could be used by a malicious application to hijack an existing Qt for Android application on the same device. The vulnerabilities in question were found by JPCERT Coordination Center, and have been assigned the following vulnerability IDs: JVN#27342829 and JVN#67389262.

These vulnerabilities have subsequently been fixed in Qt 5.9 as well as the Qt 5.6 branch of Qt. Qt 5.9.3, which was released today, contains all required patches.

For users of Qt 5.7 or Qt 5.8, we have prepared patch sets which can be applied to the source tree in order to fix these issues. They can be downloaded from Qt Account or by accessing these links: 5.6.3, 5.7.1 and 5.8.0. The patches are organized in qtbase/ and qttools/ subfolders for the code repositories where changes are needed.

Thanks to Bogdan Vatra from KDAB for supplying the necessary patches on short notice.

The post Security advisory about Qt for Android appeared first on Qt Blog.


The Qt Company Blog: Qt 5.9.3 Released

$
0
0

I am pleased to inform that Qt 5.9.3 is released today. As a patch release Qt 5.9.3 does not add any new functionality, focus is in bug fixes and performance improvements.

Compared to Qt 5.9.2, the new Qt 5.9.3 contains over 100 bug fixes and in total more than 500 changes since Qt 5.9.2. For details of the most important changes, please check the Change files of Qt 5.9.3.

Qt 5.9.3 release also contains the latest security fixes, including fixes to the two vulnerabilities in Qt for Android port.

Our intention is to make frequent patch releases for Qt 5.9 LTS. Qt 5.9.4, planned for January 2018, will bring the the next set of bug fixes from Qt 5.9 branch.

If you are using the online installer, Qt 5.9.3 can be updated to 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.9.3 Released appeared first on Qt Blog.

The Qt Company Blog: Qt Creator 4.5 RC released

$
0
0

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

We think that we are pretty close to what we want to release as Qt Creator 4.5.0, so please take this opportunity to give us final feedback through the bug tracker, our mailing list, or on IRC (#qt-creator on chat.freenode.net). For information about the new features and improvements in this version, please have a look at the beta blog post or our change log.

Get Qt Creator 4.5 RC

The opensource version is available on the Qt download page, and you find commercially licensed packages on the Qt Account Portal. Qt Creator 4.5 RC is also available under Preview>Qt Creator 4.5.0-rc1 in the online installer (as an update to the beta). 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.5 RC released appeared first on Qt Blog.

The Qt Company Blog: Migrate Your Legacy Code to Qt

$
0
0

Companies from various industry domains came to migrate their code built with Qt 3, Qt 4, MFC, Adobe Flash, Motif, HTML5, and many others to Qt 5. We’ve witnessed how the transformation to comprehensive, open architecture software framework can provide a fresh momentum to create opportunities for business growth that wouldn’t otherwise exist.

Benefits of migrating to Qt

There comes a point where further investment in unsupported or suboptimal technology isn’t sustainable anymore. So often legacy applications and UIs are not meeting demands for high performance, portability, and adaptability. Most noteworthy, the high cost of ownership that provided at least somewhat of a return on investment is not anymore aligned with steep growth demands. As a result, the market differentiation that comes with flawless user interfaces can’t be regarded as secondary.

At the same time, we have seen that technology migration projects are sometimes viewed as a major undertaking fraught with risk and uncertainty. Despite the perceived ambiguity towards change, more often than not there could be significantly bigger risks with side-stepping migration. Many businesses are realizing this and those with a clear commitment to change are reaping the rewards.

In brief, there are various benefits of migrating to Qt:

  • Less technical risks
  • Performance boost
  • High flexibility and adaptability
  • Improved maintainability
  • Future proof strategy

Want to migrate to Qt quickly?

The pain of change may not be as great as you think if you go through it with expert help. Experts from The Qt Company and our Service Partners know all the tricks of the trade. This is because they have a clear vision of what your clients and business need. Due to that, they can achieve porting quickly and with appropriate control and risk mitigation.

The set of proven steps to make sure you migrate smoothly

  • Advisory Services: Starting with an in-depth assessment of your current status. As a result, your migration roadmap will be tuned to your unique challenges. Delivery will consist of a comprehensive report accompanied with risk-reward and cost and time estimate for potential migration.
  • Porting Services: With the migration strategies, tools, and techniques in place, it’s time for putting the plan into action.
    • Convert the old structure into the modern model/view architecture
    • Execute migration to Qt with proven roadmap
    • Replace some features with new custom-made components
    • Send back ready-to-ship new application
  • Training Services: Tailored for high impact, we ensure a smooth handover training. With lectures, discussions, examples and hands-on programming labs, your team will learn how to continue to get the most out of Qt.
  • Qt Support Services: First-class support to keep things running. The team works closely with R&D engineers to help developers approach complex technical tasks

Please contact The Qt Company Consulting Services or Qt Service Partners for help in migrating to Qt.

The post Migrate Your Legacy Code to Qt appeared first on Qt Blog.

The Qt Company Blog: Security advisory about Qt for Android

$
0
0

Two vulnerabilities have been identified in Qt for Android which could be used by a malicious application to hijack an existing Qt for Android application on the same device. The vulnerabilities in question were found by JPCERT Coordination Center, and have been assigned the following vulnerability IDs: JVN#27342829 and JVN#67389262.

These vulnerabilities have subsequently been fixed in Qt 5.9 as well as the Qt 5.6 branch of Qt. Qt 5.9.3, which was released today, contains all required patches.

For users of Qt 5.7 or Qt 5.8, we have prepared patch sets which can be applied to the source tree in order to fix these issues. They can be downloaded from Qt Account or by accessing these links: 5.6.3, 5.7.1 and 5.8.0. The patches are organized in qtbase/ and qttools/ subfolders for the code repositories where changes are needed.

Thanks to Bogdan Vatra from KDAB for supplying the necessary patches on short notice.

The post Security advisory about Qt for Android appeared first on Qt Blog.

V-Play Engine: Release 2.14.0: Live Code Reloading for Desktop, iOS & Android

$
0
0

V-Play 2.14.0 adds Live Code Reloading for Desktop, iOS & Android. It allows you to run and reload apps & games within a second on iOS and Android from Windows and Linux. No Mac and Android SDKs required. It also updates the way we distribute Android & iOS updates. If you have V-Play for iOS or Android installed, make sure to follow the steps described here.

Live Code Reloading

Building your project takes some time. For mobile platforms it can even take several minutes, depending on your development PC. This can become quite time-consuming. For example if you are doing small iterations to fine-tune UI elements in apps. Same with animations, game-mechanics and so on. It slows down your development speed and therefore decreases your productivity.

V-Play Live reloads your project on every connected device, within seconds after code changes. This reduces the long compilation and deployment times, to only a couple of seconds. V-Play Live also allows you to run and test your applications on iOS from a Windows or Linux desktop. You don’t need to install any native SDKs for deployment with V-Play Live. See here for a quick demo:

This video shows a project opened in Qt Creator (left) on Windows. The project runs with V-Play Live. In the bottom right corner, the screens from an Android Nexus 7 and an iPhone 5s are shared with screen mirror tools so you can see what is going on there. In the center, you can see the desktop client. After connecting the 2 devices to the Live Server (top right), we change the code in Qt creator. After we save the changes, all connected clients update their view, within a second!

How to Use V-Play Live

1. Get the Latest Version of V-Play

If you haven’t installed V-Play yet, go get it on our download page. V-Play Live is available starting with this V-Play version, 2.14.0. If you are running an older V-Play version, see the update instructions below.

Note: This feature is available on Windows only at the moment. Linux and macOS developers will receive an update including V-Play Live next week.

2. Start V-Play Live

To start V-Play Live for your active project, click on the LIVE-Run button in Qt Creator:

v-play-live-run-button

The V-Play Live Server (below right) will start, and open a local V-Play Live Client (below left).

vplay-live-server-and-client-ui

The Live Server allows you to:

  • Manage your connected clients, both desktop and mobile.
  • See the log output of each connected client in a separate tab.
  • Detect code changes and reload all connected clients.
  • Select the qml file you would like to run. The default is the main entry point.

3. Connect Live Clients

If you do not want to connect any mobile device now, you are already set and can start development with your local Client. To connect a mobile device, download the V-Play Live App, for Android or iOS.

Google_Play_Badge-1App Store
ic_launcherV-Play & QML Live Scripting App
Search in App Stores for: “V-Play Live Scripting”

 

V-Play Live uses your local network to communicate between Server and Clients. Make sure that your device is connected to the same network as your development PC running the Live Server, for example the same WiFi. Once you run the V-Play Live App on your mobile device, it will connect to the Server. You will see this dialog in the Live Server:

vplay-live-client-connection-requesti

Accept the mobile device connection on the Server. Now all code changes are automatically sent to your connected mobile device(s).

 

V-Play Live Reload Benefits

Save Time: Deploy and Test in Seconds

V-Play Live reduces deployment time, from several minutes to a couple of seconds. It deploys your code changes to all connected devices, automatically after saving.

Let’s play a bit with numbers. If you have a really decent development PC, you might be able to deploy your application to Android within one minute. With V-Play Live, it will take 1-2 seconds.

1 - newTime/oldTime = 1 - 2/60 = 0.9667

You just saved 96.67% of time for deployment. If you deploy only 10 times per hour, you spent 20 seconds deploying, instead of 10 minutes. That is 2 extra coffee breaks per hour. Or more time to spend productive.

In this demo you see all connected clients (Desktop, Android and iOS) update within a second after clicking save in the development environment:

v-play-live-code-change-reload-windows-android-ios

Feel free to do the calculation with numbers that are more realistic in your own case.

Test on All Your Devices at Once

You can connect as many devices as you want, and every single one is updated simultaneously. We didn’t even include this in the calculation above.

Easy Setup

Setting up V-Play Live is as easy as it gets. In fact, there is nothing to set up. To connect your mobile devices, just download and install the V-Play Live App for Android or iOS.

iOS Deployment from Windows & Linux

With V-Play Live, you can test your V-Play projects on your iPhone and iPad, even from Windows or Linux. No more need to ask your office neighbor with that shiny Mac, to test you application on iOS.

No Native SDKs Required

You don’t need to install native mobile SDK for Android or iOS for developing and testing.

Debug Log Output on Mobile Devices

The Live Server displays debug log output from any connected client, including the mobile clients for iOS and Android. You can debug issues on different platforms even easier now.

Test V-Play Plugins Easily

plugins

Test V-Play Plugins like Admob Ads, Facebook Login, Google Analytics, Firebase or push notifications. With V-Play Live you can skip the individual setup steps.

Qt Quick / QML Applications

V-Play Live can also be used for Qt Quick applications and files without V-Play.

Your Source Code is Safe

V-Play Live works simple and safe, using your private local network. The Live Server is running locally on your development PC. You can connect your mobile devices using the Live Client app, available for Android and iOS. Your project files are transferred directly from your server to the clients, without ever leaving the local network.

 

Important Update Notes for existing Android & iOS Projects

With this update, developers for Android & iOS 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.

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. Open the MaintenanceTool and select the Add or remove components option:
    windows-installer-v-play-add-components
  2. Add the V-Play packages for Android and iOS:
    v-play-2.14.0-initial-state-qt-5.9.2-selected
  3. Unselect the Qt 5.9.2 package like shown below:
    v-play-2.14.0-updated-state-qt-5.9.2-unselected
  4. In Qt Creator, now choose the new kit for Android and iOS based on V-Play packages:
    v-play-2.14.0-updated-state-qt-creator-kit

 

Support for Xcode 9

With update 2.14.0, we updated all our wizards and examples to be compatible with iOS apps submitted to the App Store with Xcode 9. If you still use a previous version of Xcode, you can optionally perform these steps or do them as soon as you’re switching to Xcode 9.

Apps submitted with Xcode 9 need an Asset catalog. You can copy the Asset catalog we provide and modify it to your needs:

xcode9-asset-migration-steps

To migrate your existing project to the new format, perform steps described in this guide.

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!

 

 

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.14.0: Live Code Reloading for Desktop, iOS & Android appeared first on V-Play Engine.

The Qt Company Blog: Qt Quick Controls 2: Imagine Style

$
0
0

Back in April we wrote about image-based styling for Qt Quick Controls 2. Since then, we have made good progress and nailed down some aspects that were still under consideration. We call the new style “Imagine”.

The style works by scanning a directory of images and applying those images to the controls. For example, when a Button is created, the style will look for button-background.9.png (or button-background.png for non-resizable buttons). As an example of what that image could look like, here’s button-background.9.png from the default assets:

Imagine Style Button background image.

When the user presses the button, the style then looks for button-background-pressed.9.png (or button-background-pressed.png). In the case of the default assets, that would look like this:

Imagine Style pressed Button background image.

The .9.png extension represents 9-Patch images. Using this format, we’re able to encode information about how the control should look when it is resized into the image itself. Combine this with the pre-defined file naming convention and you’ve got a style that can be customized without ever touching QML, giving designers complete control over what they do best, and allowing developers to focus on writing applications, not styles.

To provide a starting point for creating your own style, we’ve created a complete asset template in Sketch:

Default Imagine style Sketch template

Default Imagine style Sketch template (Sketch)

For those who prefer Illustrator or Photoshop, we’ve provided smaller templates, each with their own example that uses the assets:

Qt Quick Controls 2 - Imagine Style Example: Automotive

Qt Quick Controls 2 – Imagine Style Example: Automotive (AI)

Qt Quick Controls 2 - Imagine Style Example: Music Player

Qt Quick Controls 2 – Imagine Style Example: Music Player (PSD)

The Imagine style is available with Qt 5.10. For more information, see the documentation.

The post Qt Quick Controls 2: Imagine Style appeared first on Qt Blog.

The Qt Company Blog: Are you ready for Qt Quick Controls 2.3?

$
0
0

This blog post takes a brief look at some of the new features in Qt Quick Controls 2.3 released as part of Qt 5.10. See also New Features in Qt 5.10 for a more detailed list.

New styles

We are introducing two new styles: Fusion and Imagine. The Fusion style looks familiar to those who have been using Qt Widgets. This is a QML-based implementation of the same design.

The Fusion style

The Fusion style

The Imagine style is based on configurable image assets, giving designers full control over how the style looks like. The style comes with a default set of image assets that have been exported from Sketch.

The Imagine style

The Imagine style

With the Imagine style it is possible to style the controls without a single line of code. There will be also examples for Illustrator and Photoshop. These designs are provided as starting points for those creating their own designs. See Qt Quick Controls 2: Imagine Style from Mitch for more details.

Menus and actions

Menus and friends have taken big steps forward. We have added new QML types called MenuBar, Action and ActionGroup, and Menu has gained support for sub-menus. It is now possible nest menus, as expected on desktop platforms. We also added support for mnemonics in menus and buttons.

MenuBar and cascading Menus

MenuBar and cascading Menus

The usage is identical to the earlier generation of Qt Quick Controls:

import QtQuick 2.10
import QtQuick.Controls 2.3

ApplicationWindow {
    id: window
    width: 500
    height: 400
    visible: true

    menuBar: MenuBar {
        Menu {
            title: qsTr("&File")
            Action { text: qsTr("&New...") }
            Action { text: qsTr("&Open...") }
            Action { text: qsTr("&Save") }
            Action { text: qsTr("Save &As...") }
            MenuSeparator { }
            Action { text: qsTr("&Quit") }
        }
        Menu {
            title: qsTr("&Edit")
            Action { text: qsTr("Cu&t") }
            Action { text: qsTr("&Copy") }
            Action { text: qsTr("&Paste") }
            MenuSeparator { }
            Menu {
                title: qsTr("&Find/Replace")
                Action { text: qsTr("Find &Next") }
                Action { text: qsTr("Find &Previous") }
                Action { text: qsTr("&Replace...") }
            }
        }
        Menu {
            title: qsTr("&Help")
            Action { text: qsTr("&About") }
        }
    }
}

These are important steps bringing Qt Quick Controls 2 menus functionality-wise on par with native platform menus. This makes it feasible to start considering the next steps integrating native platform menus as a backend for Qt Quick Controls 2 menus.

Palettes

We have added support for configurable palettes, currently supported by the Default, Fusion, and Imagine styles. The other styles are coming later. Here’s a screenshot of the Default style with a custom dark palette:

The Default style with a custom dark palette

The Default style with a custom dark palette

Q & A:

What about TableView?
– We have made great progress with a new TableView based on the same Qt Quick item view framework ListView and GridView are based on. The current implementation is already able to manage a two-dimensional set of visible items for the current viewport. The performance is on the same level with ListView and GridView. Large amount of columns does not kill the performance like in the ListView-based TableView in Qt Quick Controls 1. Stay tuned for a blog post on the subject.

When is the famous “Object destroyed during incubation” problem going to be fixed?
– We believe we have now the necessary ingredients for finally tackling this issue. I have prepared a patch to the QML engine that allows us to defer the execution of the built-in delegates so that a) replacing them with custom delegates at construction time won’t cause troubles for asynchronous incubation and b) the performance (in terms of construction time) of a customized control is not affected by the built-in delegates. As soon as the necessary patch to the QML engine has landed, we can start making use of it in Qt Quick Controls 2. We are targeting the 5.9.x LTS series. I’ll report status updates to QTBUG-50992.

The post Are you ready for Qt Quick Controls 2.3? appeared first on Qt Blog.


The Qt Company Blog: Say hello to Qt Quick Pointer Handlers

$
0
0

We’ve known for several years that our multi-touch support in Qt Quick has been inadequate for many use cases.  We have PinchArea, to handle two-finger scaling, rotation and dragging; and MultiPointTouchArea, which can at least be used to show some sort of interactive feedback for the touchpoints, or maybe you could write a little state machine in JavaScript to recognize some kind of gesture.  As for the rest of Qt Quick though, the main problems are 1) support for mouse events came first; 2) Qt assumes there is only one mouse (the “core pointer”); 3) QMouseEvent and QTouchEvent (and a few more) have no suitable intermediate base class, so they end up being delivered independently; 4) that being hard, shortcuts were taken early on, to treat touch events as mouse events and deliver them the same way.  So the result is that you cannot interact with two MouseAreas or Flickables at the same time, for example.  This means you cannot press two Buttons at the same time, or drag two Sliders at the same time, if they are implemented with MouseArea.

At first I hoped to fix that by making MouseArea and Flickable both handle touch events separately.  The patches to do that were quite complex, adding a lot of duplicated logic for the full parallel delivery path: a QMouseEvent would take one path and a QTouchEvent would take another, in the hope that the interaction would work as much the same as possible.  It was months of work, and at the end it mostly worked… but it was hard to keep all the existing autotests passing, and colleagues worried about it being a behavior change.  MouseArea proclaims by its name that it handles mouse events, so as soon as it begins to handle touch events separately, it becomes a misnomer.  Suddenly you would be able to press two Buttons or Tabs or Radio Buttons at the same time, in applications and sets of controls which weren’t designed for it.  (So we tried adding a bool property to opt in, but needing to set that in every MouseArea would be ugly.)  MouseArea and Flickable also need to cooperate a lot, so the changes would have to be done together to keep everything working.  It was possible, but narrowly missed shipping in Qt 5.5 due to uncertainty.

So eventually we took a different route, after we found a reasonable combination of ideas that had been proposed.

One idea was that since we cannot refactor the QEvent hierarchy (yet) due to the binary compatibility mandate, we could instead create wrapper classes which make the events look like we want them to, complete with properties for the benefit of QML, and deliver those instead, using a mostly-unified event delivery path in QQuickWindow and QQuickItem.

Another idea was the realization that dynamically creating and destroying these wrapper events is silly: instead we use a pool of instances, as we have been doing in other cases where an “event” object is emitted by a signal (for example the object emitted by MouseArea.positionChanged is always the same instance, since Qt 5.8).  With that optimization, wrapping one event with another is no longer a big performance hit.

Another idea was suggested: maybe it would be nice if handling an event from a pointing device were as easy as using the Keys attached property: for example, Mouse.onClicked: { ... } or PointingDevice.onTapped: { ... } But soon after came the realization that there can be only one instance of an attached property per Item to which it is attached.  One of the problems with MouseArea is that it tries to do too much, so it didn’t make sense to simply re-implement all the functionality in a monolithic MouseAttached.  We wanted the ability to handle a click or a tap without caring which device it comes from, for example, because that’s what every Button control needs to do.  It’s the same with any gesture that can be performed with either the mouse or a single finger.  Perhaps there could be one attached property per gesture rather than one per device type, then?

Since QML is a declarative language, it’s nice to be able to declare constraints rather than writing if/else statements in JavaScript signal callbacks.  If an object which handles events is designed not to care which device a gesture comes from, there will nevertheless be cases when your application does care: you want to perform a different action depending on whether it is tapped on the touchscreen or clicked with the right mouse button, or you want to do something different if the control key is held down while dragging an object.  By allowing multiple instances of these handler objects, we can declare the constraints on them by setting properties.  It should be OK to have as many instances as you like.  Each instance should be lightweight so that you don’t fear to have too many instances.  The implementation should be in C++, and it should be simple and understandable.  Each handler should do one, or at most a few very closely-related things, and do them well.

Those concerns have taken us away from the idea of using attached properties, for now.  What we have instead is a new family of classes in Qt Quick: Pointer Handlers.

A Pointer Handler is a type of object which you can declare inside any Item, which handles events from pointing devices on behalf of that Item.  You can declare as many of them as you need: typically, one per interaction scenario.  All the common constraints that we could think of are declarable: you can make the handler react only if it’s a touch event, only to certain mouse buttons, only if the correct number of fingers are pressed within the bounds of the Item, only if a particular modifier key is held, etc.

Draggin’ balls

Common gestures are represented by their own handler types.  For example, if you declare

Rectangle {
    width: 50; height: 50; color: "green"
    DragHandler { }
}

then you have a Rectangle which can be dragged around the scene via either mouse or touch, without writing any Javascript, and without even needing to bind the handler to its parent in any way.  It has a target property, and the default is the same as its parent.  (But by setting the target to a different Item, you can capture events within one item, but manipulate the other.)

Of course, if you have two of those green rectangles with DragHandlers in them, you can drag them both at the same time with different fingers.

Every Pointer Handler is a QObject, but it’s not a QQuickItem, and it doesn’t have too many of its own variables, so each instance is about as small as a practical QObject subclass can be.

Every single-point handler has the point property, to expose all the details about the touchpoint or mouse point that we can find. There are properties for pressure and ellipseDiameters: some devices may have force sensors, while others may measure the size of the contact patch (but many devices don’t provide either). It has a velocity property which is guaranteed to be defined: we calculate and average the velocity over the last few movements for a slightly smoother reaction. Having the velocity available could potentially enable velocity-sensitive gestures: perhaps a flick should be done at a certain minimum speed. (Is that the right way to distinguish a flick from a drag? It hasn’t been easy to make that distinction before.) Or, if you have the velocity at the time of release, a drag gesture can end with momentum: the object keeps moving a short distance in the same direction. This makes your UI feel more alive. So far we have not formalized MomentumAnimation into a supported animation type, but there is a pure-QML prototype of it in tests/manual/pointer/content/MomentumAnimation.qml.

two red balls being dragged simultaneously with DragHandler

Tap dancing

TapHandler handles all the press-and-release gestures: single quick taps or clicks, double-taps, some other number of taps, holding it pressed for a configurable period of time, or holding it for various periods of time, all in unique ways. (When you touch a touchscreen, it often doesn’t make any sound, but you can tap a mouse button; so we thought “tap” is a more future-proof name for this gesture than “click”.)  You can show feedback proportional to how long it has been held (an expanding circle, progress bar or something like that).

TapHandler detecting a triple-tap and then a long press

Pinch me if this is for real

There is a PinchHandler.  If you declare it inside an Item, you will be able to scale, rotate and drag that Item using the pinch gesture.  You can zoom into any part of the Item that you like (an improvement on PinchArea).  It can handle larger numbers of fingers, too: you can declare PinchHandler { minimumTouchPoints: 3 } to require a 3-finger pinch gesture.  All the transformations then occur relative to the center point between the three fingers, and the scaling is relative to the average increase or decrease in spread between them.  The idea came from the way that some versions of Ubuntu use the 3-finger pinch for window management: apparently they thought the content in the window may have some use for a 2-finger gesture, but most applications don’t use 3 fingers for anything, so it’s OK to reserve the 3-finger pinch to scale and move windows around the desktop.  Now since you can write a Wayland compositor in QML, you can easily recreate this experience.

zooming into a map with PinchHandler

Getting to the points

Finally, there is PointHandler.  Unlike the others, it doesn’t manipulate its target Item: it exists only to expose the point property.  It’s similar to an individual TouchPoint in MultiPointTouchArea, and can be used for the same purpose: to provide interactive feedback as touchpoints and the mouse cursor move around the scene.  Unlike MultiPointTouchArea, it does not exclusively grab the touchpoints or the mouse, so having this interactive feedback does not prevent interacting with other handlers in other Items at the same time.  In the animations on this page, it’s used to get the finger sprites to follow my fingers around.

Are we there yet?

So now I’ll get to the reasons why this stuff is in Tech Preview in 5.10.  One reason is that it’s incomplete: we are still missing support for mouse hovering, the mouse wheel, and tablet stylus devices (a stylus is still treated as a mouse for now).  None of the handlers have velocity-sensitive behavior.  We can imagine a few more Handlers that could be written.  There should be public C++ API so that you can create your own, too.  Handlers and Flickable are getting along somewhat, but Flickable is a complex monolithic Item, and we think maybe it can be refactored later on.  There is a FakeFlickable manual test which shows how it’s possible to re-create a lot of its functionality in QML with two ordinary Items, plus a DragHandler and a few animations.

FakeFlickable: a componentized Flickable

Another reason is the naming. “Pointer Handlers” sounds OK in isolation, but there is pre-existing terminology which makes it confusing: a pointer might be a variable which points to a memory location (but that’s not what we mean here), and a handler might be a sort of callback function that you write in JavaScript.  If you write TapHandler { onActiveChanged: ... } do you then say that your handler has a handler?  We could start using the word “callback” instead, but it’s an anachronism in some circles, and in QML our habits are hard to change now.

Another reason is that QtLocation has some complex use cases which we want to use as a case study, to prove that it’s possible to navigate a map (and any interactive content upon it) with small amounts of readable code.

Perhaps I’ll continue this later with another post about another way of doing gesture recognition, and how that might affect how we think about Pointer Handlers in the future.  I haven’t explained the passive grab concept yet.  There’s also more to be defined about how to build components which internally use Pointer Handlers, but give the application author freedom to override behavior when necessary.

So to wrap up for now, Pointer Handlers are in Tech Preview in 5.10.  We hope you will play with them a lot.  Especially if you have some old frustrations about interaction scenarios that weren’t possible before.  Even more so if you ever wanted to create a touch-intensive UI (maybe even multi-user?) without writing a C++ event-forwarding and QObject-event-filtering mess.  We need to start getting feedback from everyone with unique use cases while we still have the freedom to make big changes if necessary to make it easy for you.

So far the usage examples are mostly in tests/manual/pointer.

Since it’s in tech preview, the implementation will continue to be refined during the 5.10 series, so follow along on the 5.10 git branch to keep up with the latest features and bug fixes.

The post Say hello to Qt Quick Pointer Handlers appeared first on Qt Blog.

KDAB on Qt: Writing a Custom Qt 3D Aspect – part 1

$
0
0

Introduction

Qt 3D has a flexible and extensible architecture that allows us to easily add our own new functionality to it without disrupting the existing features.
The functionality of Qt 3D is divided among so-called aspects, each of which encapsulates a particular subject domain such as rendering, input, or animation.

This short series of articles will walk you through the process of adding a new aspect that provides component types and behaviour for a new domain not covered by Qt 3D out of the box. For this example we have chosen to implement an aspect that allows calculating running means of the frame rate. Of course this could legitimately be added to the renderer, but it's simple enough that it makes a nice example for our purposes today. The full source code for the example is available for download.

Overview

The application that we will build looks like this. It's a very simple Qt 3D scene and the window shows the current mean frame rate.

Custom Aspect Screenshot

There are a few parts that we need to consider when adding such new functionality (see the diagram):

  • Aspect— Responsible for orchestrating any jobs that need executing each frame and for managing the storage of any backend objects.
  • Components— Provided by your library/application are what an Entity will aggregate to give it new behaviour. The components are the main API you will need to create.
  • Nodes— Just as for components except that subclasses of QNode typically provide supporting data required by a component.
    For example QAnimationClipLoader is a node that provides animation key frame data to a QClipAnimator component.
  • Backend Nodes— The backend counterparts to any frontend components or nodes provided by your library/application. These are the objects typically processed by jobs running on the threadpool as dictated by the aspect itself.
  • Mapper— Custom mappers are registered with the aspect and are responsible for creating, fetching, and destroying backend nodes on demand. The mapper is used by QAbstractAspect and QAspectEngine to synchronise lifetimes of the frontend and backend objects.
  • Jobs— Created and scheduled by the aspect and which process the backend nodes. Jobs may also send events to the frontend nodes and components if properties change.
  • Change Arbiter— Responsible for delivering events between and among the frontend and backend objects. No need to do anything with this but be aware of its existence.

Adding the Aspect

Writing the initial aspect itself is really trivial. Just subclass QAbstractAspect and register it with the QAspectEngine:

[sourcecode lang="cpp" title="customaspect.h"]
class CustomAspect : public Qt3DCore::QAbstractAspect
{
Q_OBJECT
public:
explicit CustomAspect(QObject *parent = nullptr)
: Qt3DCore::QAbstractAspect(parent)
{}

protected:
QVector jobsToExecute(qint64 time) override
{
qDebug() << Q_FUNC_INFO << "Frame time =" << time;
return {};
}
};
[/sourcecode]

[sourcecode lang="cpp" highlight="6" title="main.cpp"]
int main(int argc, char **argv)
{
QGuiApplication app(argc, argv);
Qt3DExtras::Quick::Qt3DQuickWindow view;

view.engine()->aspectEngine()->registerAspect(new CustomAspect);

view.setSource(QUrl("qrc:/main.qml"));
view.show();
return app.exec();
}
[/sourcecode]

QAbstractAspect has a few more virtuals that you can override to do initialisation and cleanup should you need them. However, for this simple example all we need to do is to implement the jobsToExecute() virtual. Later we will use this to schedule a job to execute on the threadpool each frame, but for now we just output some debug text to return an empty vector (no jobs to run). Note that these virtual functions will only be called once you have registered the aspect with the QAspectEngine (see above) so that it is part of the simulation. We will return and complete the aspect a little later.

The FpsMonitor Component

We wish to add functionality to report on the mean frame rate averaged over a given number of frames. With this is mind we might come up with an API something like this:

[sourcecode lang="cpp" title="fpsmonitor.h"]
class FpsMonitor : public Qt3DCore::QComponent
{
Q_OBJECT
Q_PROPERTY(int rollingMeanFrameCount READ rollingMeanFrameCount WRITE setRollingMeanFrameCount NOTIFY rollingMeanFrameCountChanged)
Q_PROPERTY(float framesPerSecond READ framesPerSecond NOTIFY framesPerSecondChanged)

public:
explicit FpsMonitor(Qt3DCore::QNode *parent = nullptr);

float framesPerSecond() const;
int rollingMeanFrameCount() const;

public slots:
void setRollingMeanFrameCount(int rollingMeanFrameCount);

signals:
void framesPerSecondChanged(float framesPerSecond);
void rollingMeanFrameCountChanged(int rollingMeanFrameCount);

private:
float m_framesPerSecond;
int m_rollingMeanFrameCount;
};
[/sourcecode]

Note that we use a declarative, property-based API so that this class can easily be used from QML as well as from C++. The property rollingMeanFrameCount is a regular read-write property and the implementation of the setter and getter functions are completely standard. This property will be used to control the number of frames over which we calculate the moving average frame rate. The framesPerSecond property is a read-only property which will later be set from a job that we will write to process FpsMonitor components on the Qt 3D threadpool.

Creating a Small Test Application

Before we can utilise our custom component from QML, we must register the type with the QML type system. This is a simple one-liner that we can add to our main function:

[sourcecode lang="cpp" title="main.cpp"]
qmlRegisterType("CustomModule", 1, 0, "FpsMonitor");
rootContext->setContextProperty("_window", &view);
[/sourcecode]

where we also took the opportunity to export the window to the QML context too (we'll need that in a moment).

Once that is done, we can import the CustomModule QML module and make use of the FpsMonitor component just as we would for any of the built in types.

[sourcecode lang="js" title="main.qml"]
Entity {
components: [
FpsMonitor {
rollingMeanFrameCount: 20
onFramesPerSecondChanged: {
var fpsString = parseFloat(Math.round(framesPerSecond * 100) / 100).toFixed(2);
_window.title = "CustomAspect: FPS = " + fpsString
+ " (" + rollingMeanFrameCount + " frame average)"
}
}
]
}
[/sourcecode]

Of course at this point, the FpsMonitor doesn't do much except for setting the value of the rollingMeanFrameCount property. Once we complete the backend, the above code will update the window title to show the current mean frame rate and the number of frames used to calculate it.

In the next part we will implement the corresponding backend node for FpsMonitor and make sure it gets created and destroyed on demand and set up communications between the frontend and backend.

continue reading

The post Writing a Custom Qt 3D Aspect – part 1 appeared first on KDAB.

Qt – moiji-mobile: QtVirtualKeyboard on Wayland

$
0
0

For the last couple of years my focus was on the Osmocom project to bring Free Software to the world of telecommunication. With a group of enthusiasts we have implemented the components necessary to run a complete network using Free Software. The Rhizomatica project is using the software to connecting people that were left behind. Our tools enabled high impact security research leading, leading to improvements to privacy and security for all of us….

But during the last months I had the opportunity to return to C++ and Qt work and it feels like coming home to the world of ARM powered hardware. When I left, the transition from consumer electronics (e.g. settop boxes) to automative (e.g. IVI) began and it seems it successfully completed! On Friday I explored a regression in OpenSSL and today I had the pleasure to understand input method handling of wayland a little bit better.

I wanted to see if I can use wayland and run QtVirtualKeyboard only in the Compositor. I couldn’t find answers in the documentation and started to read the code. Once I understood how it should work, I found a simple example in QtWayland. Isn’t Qt wonderful?

As I have gone down the rabbit hole let me try to share some of my reading. At the core is the unstable (API subject to change) text-input protocol. Upstream of wayland-protocols is still at v1 of the protocol but QtWayland includes a copy of v2 and has rather complete support for the compositor and client (thanks KDAB!).

Compositor/Server

To make it work the compositor needs to signal support for the “zwp_text_input_manager_v2” interface. In QML/Quick this needs to be done by adding the following inside the WaylandCompositor component:

...
TextInputManager {
}
...

This will instantiate a QWaylandTextInputManager and call ::initialize on it. Then auto-generated code will use wl_global_create to register the interface in the global registry. Clients will request a text_input and the manager will create one or use a QWaylandTextInput and then send events down to the client. E.g. if there is a soft keyboard set a breakpoint in QWaylandTextInput::sendKeyEvent in the compositor and see from where it is coming and how it will send the event to a client.

Client

Once the client starts the QWaylandIntegration will create a QWaylandDisplay and then query/initialize the registry. The answer will call QWaylandDisplay::registry_global for every registered interface. For the the zwp_text_input_manager_v2 interface the integration will initialize a QtWayland::zwp_text_input_manager_v2 and for each input device a QtWaylandClient::QWaylandTextInput (different namespace) will be created.

Communication

Now Compositor and Client will communicate through the wayland connection (no dbus). With Qt APIs the client will notice which element has been focused and will request the input method to be shown (QtWaylandClient::QWaylandInputContext::showInputPanel) and the Compositor  will forward this to the QInputMethod (see QWaylandTextInputPrivate::zwp_text_input_v2_show_input_panel)

Putting it together

In the end this is rather simple.. create a TextInputManager, use the InputPanel of the QtVirtualKeyboard and start your compositor with QT_IM_MODULE=qtvirtualkeyboard. Done!

 

KDAB on Qt: Porting Applications to Qt

$
0
0

https://youtu.be/Y0TgaevFKx0?rel=0&showinfo=0

KDAB has unique experience in porting the code base for toolkits like Qt 3, Qt 4, Motif, Java, Tcl, GTK, .NET, MFC, and Photon to Qt 5. Porting legacy GUI toolkits to Qt 5 is a job where proven experience saves a lot of time.

In this presentation we highlight the main problems facing developers using legacy toolkits, what migrations are and which approaches to migrations are possible. We give you a short overview of common guidelines in starting migrations including common pitfalls and also discuss how KDAB can assist in porting your legacy code base to a modern Qt-based system using our tooling for automatic conversions.

View the slides.


For detailed information on migration, read our whitepaper: Modernizing Legacy Systemscontinue reading

The post Porting Applications to Qt appeared first on KDAB.

The Qt Company Blog: Webinars in December / January: Sign up now!

$
0
0

Hi everyone!

Here’s an overview of our free webinars for the upcoming weeks. They usually take place at 6pm CET, 1pm EDT and 10am PDT so you can participate live and ask our experts any questions you may have.

Don’t have the time to participate live? Sign up anyway – we will send you a recording and the presentation slides to your email address!

7 December: Pointer handlers for Fluid Applications in Qt Quick
Over the last few years, we have discussed adding a new way in QtQuick to handle events from pointing devices such as touchscreens, mice and graphics tablets. Now it is on track to ship in Qt 5.10.

14 December: An Interactive Digital Out-of-Home Software Developed by Using Qt Libraries

An Interactive Digital Out-of-home (DOOH) software has specific requirements like astonishing real-time visual effects, multiple cameras and touch devices support, remote monitoring and control, over the air deployment, statistics and the ability to easily create eye-catching apps. This webinar will explore the different features of the interactive DOOH software and underline the integration of the Qt libraries within the software.

9 January: Meet Qt 5.10 Asia and EU time zone 11 January: US and EU time zone

Overview of the new features in the latest release of the Qt framework and tools. Qt 5.10 is a quality upgrade spiced with several new features on top of the previous release,  Qt 5.9 LTS. New features in Qt 5.10 include a mechanism to use graphical assets in UI design created and maintained in a 3rd party tool, Vulkan support, improved gesture enablers, WebGL based remote applications, solutions for M2M communications, Qt Creator 4.5 and much more.

16 January: Introduction to 3D Studio EU and Asia time zones – 18 January: US and EU time zone

In this webinar, we will go through the Qt 3D Studio key features, show how you can create interactive 3D user interfaces with Qt 3D Studio and answer your questions live.

25  January: Functional Safety with Qt and Qt Safe Renderer

In this webinar, we talk about functional safety and how the Qt Safe Renderer can be used to create functionally safe systems.

Missed a webinar such as our Qt Graphics AMA session or the one on the controversial million-dollar-question “Qt or HTML5”? No problem! You can find recordings of all our webinars in the on-demand section! Download them and get smart!

The post Webinars in December / January: Sign up now! appeared first on Qt Blog.

Viewing all 15410 articles
Browse latest View live