Friday, September 8, 2017

pkg_config and qmake

If you're developing an application with Qt which in turn relies on some library that uses the pkg-config tool, you can take advantage and simplify your Qt project file (.pro) as it will help avoiding hard-coded values for where to find headers and libraries for a particular package.

Using a custom QNetworkAccessManager in QML

The QML Image component has the capability to specify the source of the image is as a URL (using the "source" property) and QML automatically retrieving such image file from a remote location. To do so, QML uses a QNetworkAccessManager (QNAM for short) in the background, which has a lot of default values. But what if you need to set some custom values for the QNAM?

Thursday, August 10, 2017

Internationalization with Qt VS Tools

The good news for people using Qt VS Tools addin is that translations work very well from within the Visual Studio environment. The whole lifecycle of translations in Qt, that is:

  • use tr() method to wrap all translatable strings
  • create the .ts files with lupdate command
  • translate using Linguist
  • create the compiled .qm files with lrelease command
can be carried on without any issues, see more information here.

Monday, August 7, 2017

Qt on Android: browsing files from device with QFileDialog widget in Linux

I was developing an Android application with Qt using a real device connected to my laptop with Lubuntu, and I needed to open files created by such application on Android's file system directly from my PC. The thing is, the device was auto-mounted whenever I connected it, and showing properly in the file manager (something like mtp://[usb:001,007]/), but while using QFileDialog::getOpenFileName there was no way to find the device and browse its folder structure.

Wednesday, April 5, 2017

Make the compiler fail if using deprecated Qt features

Instead of making the compiler warn you if using deprecated Qt features (see previous post), by using QT_DISABLE_DEPRECATED_BEFORE it's even possible to make your code fail to compile if you use deprecated APIs.

Make the compiler warn you of deprecated Qt features

QT_DEPRECATED_WARNINGS is a keyword that can be used in your Qt's project files (.pro) so qmake makes your compiler emit warnings if you use any feature of Qt which as been marked deprecated. The exact warnings depend on your compiler, but it'll be easy to spot any location in your source base that might be affected for any Qt's API changing soon.

Monday, April 3, 2017

Ever dreamt of creating your own QML controls?

Were you in need of a control not provided in the QML controls set? Have you wondered how difficult could such an enterprise be to write and use your own QML control to fit your needs? Do you feel like contributing any new QML control back to the community?