Posts

Showing posts with the label Qt

Get local active IP address

Image
The active IP address would be the one actually used to communicate on the network. In most cases a PC has the ethernet port used as primary and the wifi network used as secondary (or vice versa). If you switch from one to the other you create a situation where both network devices have a valid IP but only one of the two is actually used based on the active connection at that time.

QWebSocket synchronous communication

Image
QWebSocket can send or receive packet with text or binary contents. As all other Qt components everything works asynchronously. However, there may be cases where it is necessary to work asynchronously waiting for the reply to a given message before moving on. Here an example for a synchronous communication that you can use in your project.

QML: Emboss effect

Image
QML have some components allowing to draw a shadow over an item. The InnerShadow draw a shadow only in one side of the item, but for have the emboss effect we need to habe both sides with light/dark color. The solution is very simple, use two InnerShadow combined.

QML: CheckBox and RadioButton with description field

Image
Restarting from this post explaining how to add the word wrap feature to the CheckBox and RadioButton controls here will propose to add a description field under the main control text. This will be useful to give a short explanation concerning the use of the control itself.

Qt: Request Android app permissions

Image
Each Android app, based to the "interaction" with system, have to declare what resources need to access through some special info called permissions . Normally these permission are declared inside the AndroidManifest.xml and this was enough. However, from android version 23 (Marshmallow) and above some part of these permissions (classified as more "critical") have to be manually requested to the user who have to accept for authorize the app to use it.

QML: CheckBox and RadioButton with word wrap feature

Image
Standard QML CheckBox and RadioButton controls can be used in a very easy way but, at least until the current date, it have the problem if the text go over the parent control container is not automatically moved to the next line but is simply cutted out. This missing feature is called word wrap .

Qt Installer: show uninstall window only

Image
Qt Installer Framework is the multiplatform installer solution provided by Qt team. Is a powerful tool but customization is currently not so easy cause no visual tool has been provided and all the customizations have to be done by code.

QML: Get Android apk package info

Image
All the information stored inside apk AndroidManifest.xml file can be extracted using dedicated Android API. Using JNI through C++ Qt layer is possible to get these info and pass them to the QML level.

QML: Mixed native Android and QML animated splash screen

Image
In this blog two methods for show a splash screen has been proposed. One is based to pure QML code and show animations and the second is native Android way but static. Now a third method mixing both previous solution by allow a partially animated splash screen is proposed.

Qt Creator: set dependencies between subprojects

Image
In case your project is divided in some subprojects like, the typical case, a main app plus a library you have to be sure, when you make some change into the library, also the main app is automatically recompiled for "integrate" the new changes of the library. This operation can be done by set a dependency between the library and the app.

Qt: Load resources from static or shared library

Image
Usually Qt resource file (.qrc) is embedded inside the main executable file for automatic access without any additional operation. Just compile and you have access to the resources from any point of the code by using the special path prefix required for the resource virtual file system. However, if required, is also possible to load resources from static or shared libraries with a minimal efforts.

QML: Change Android screen orientation programmatically

Image
In case your Android app require to dynamically set screen orientation for some particular interface is possible to directly call the system API allowing to choose one of the two standard orientations LANDSCAPE or PORTRAIT.

QML: Show Android native splash screen in your QML app

Image
In this post a solution to make a pure QML splash screen has been proposed and could be used for Android app also. However, since Qt/QML app are "wrapped" inside pure Android code a solution like these could be a little slow especially in the first step of application startup. Here another solution specific for Android app more faster to show splash screen at startup.

QML: Get Android signal strength level

Image
Second post regarding how to get system info from Android to QML. This post will analyze the way to install an Android listener to be advised when phone signal strength level change.

QML: Get Android battery level and status

Image
This post will explain a way to get Android battery level and status from QML. To be more precise will explain the way to install a sort of listener that will automatically advise the QML layer about changes in level of battery charge and the status of the phone (if on charge or not).

QML: Resize controls when Android virtual keyboard come up

Image
QML have currently a bug (current version 5.8 still have) in resize window when android keyboard come up. It happen when virtual keyboard is requested the QML window show a bad flicker by repaint the top control on the center of the screen and back on top again. This look really unprofessional.

QML and Android emulator OpenGL error

Image
Lately, after an Android emulator image update, a strange error regarding OpenGL is coming up using official Android emulator. This error refer to some OpenGL failed operation and, as consequence, doesn't allow the app to run correctly. QML make a large use of OpenGL that's mean each app developed using this technology doesn't work anymore (on the emulator).

QML: Show animated splash screen at startup

Image
QML is a great way to make nice interfaces but, currently, suffer a bit in the initial phase of loading since it could take some time if your QML code is complex or there are many image resources to load. In this case show a splash screen can be a good way to "inform" the user the app is started. More better have an animation will inform also the app is alive and still loading.

Qt Creator: include additional files inside Android apk

Image
Developing an app for Android frequently require to include some additional files containing custom data used by the app itself (in majority of cases sqlite database files). Android provide a standard way by using a special folder called assets where these kind of files need to be stored. Qt Creator provide a instructions to use for copy these files during apk creation.

QML Snippet: Flickable TextArea and Material style problem

Image
Make a TextArea control flickable is a very easy task using new version 2 of QtQuick controls. However when Material style was applied it show a line on bottom side of control that, in case of full window edit control, is not so good to view.