Some Lesser Known Qt Tools and Commands

Some Lesser Known Qt Tools and Commands - Part 1

By Jeff Tranter

Every Qt developer should be familiar with the common tools like qmake, Qt Designer and Assistant, but looking in your Qt installation's bin directory will reveal a few more programs there. In this and future blogs, we'll look at some of the lesser known Qt development tools.

First, let's review a list of the tools for which you should be familiar. A few, like moc, rcc, and uic may be less familiar to you if you primarily let qmake or your IDE take care of building software, but the tools shown in the table below are ones that most Qt developers use on a regular basis.

Table 1 - Commonly Used Qt Tools
Tool Name Description
assistant Qt Assistant documentation tool
designer Qt Designer GUI layout tool
linguist Qt Linguist translation tool
lrelease Localization tool to compile ts files to qm files
lupdate Localization tool to extract translation strings and generate or update ts files
moc Qt Meta Object Compiler
qmake Qt software build tool
qmlscene QML file viewer (for Qt Quick2/Scene Graph)
qmlviewer QML file viewer (for Qt Quick 1)
rcc Qt resource file compiler
uic Qt User Interface Compiler for generating code from ui files

If any of the tools above don't look familiar, I encourage you to review the Qt documentation to learn more about them. In this post we'll look at three lesser-known tools: lconvert, pixeltool and qlalr.

Lconvert

Lconvert is one of the translation tools included with Qt. It is a command line tool that can convert between different translation file formats. It was introduced in Qt 4.5.0. If you use Qt's standard ts files for translations, you may not have occasion to use this tool. However, if you use another translation file format, like the GNU Gettext PO format, lconvert can be useful for converting to and from this format. Even if you are using the ts file format, if your translations are done by a large translation house, they may not have heard of Qt's file format. However, they may be able to supply you with translations in XLIFF (1) format. The lconvert tool can convert your translations between XLIFF and PO format. Because it is a non-graphical command line program, you may find it useful to incorporate the tool into your software build system to automate building or conversion of translation files. The tool also has some filtering capabilities. You can get further details by reading the Qt documentation.

Pixeltool

The Qt Pixel Zooming Tool, pixeltool, is a handy little graphical application that magnifies the screen around the mouse pointer so you can look more closely at individual pixels. It is useful for testing small areas of a graphical user interface (GUI), something you might need to do when developing a new custom widget or theme, for example. Pixeltool has a number of options that are accessible via a context menu. A screenshot is shown below, as well as the context (right click) menu.

Lesser Known Qt Tools and Commands  

Pixeltool has been a part of Qt for a long time, at least as far back as the early Qt 4 releases.

QLALR

A little known but occasionally very useful tool that ships with Qt is qlalr, the Qt parser generator. QLALR accepts an input file that defines a grammar and generates C++ code to generate a parser for it. It is much like the traditional UNIX Yacc (or GNU equivalent, Bison) tools. Like those tools, it accepts LALR(1) parsing grammars and supports associativity and ambiguity. Unlike these tools, however, QLALR generates Qt-based C++ code rather than plain C. It is used internally by Qt for QML's JavaScript parser and Qt's XML stream reader. The tool is not mentioned in Qt's reference documentation, but a couple of blog posts (2)(3) have been written by developers that describe it.

Summary

I hope you found this brief article regarding some of the more obscure Qt tools useful. I plan to cover more of the lesser known commands in future blog posts.

References

  1. XLIFF, Wikipedia article, accessed 12 February 2015, en.wikipedia.org/wiki/XLIFF
  2. QLALR Adventures, Using QLALR to generate a parser for a text adventure, Qt project blog post, accessed 12 February 2015, qt-project.org/quarterly/view/qlalr_adventures
  3. Developer Daze(tm) presents: A Closer Look at QLALR, Qt project blog post, accessed 12 February 2015, blog.qt.digia.com/blog/category/qlalr