In this blog post, we'll continue the series on Qt Tips and Tricks. This time I'll present some general advice on working with Qt, based on the experience of ICS developers.

Bug Tracker

If you are having a problem with Qt, the Qt Bug Tracker (1) is a useful resource to check for known bugs or other issues in Qt. It is also the place to report new bugs you find in Qt.

If you are seeing strange behavior, it might be a legitimate bug in Qt rather than an error on your part. Some of the newer Qt modules, especially those at a technical preview state, may contain bugs. If you think you have run into a bug, create a minimal self-contained test case for it and report it on the bug tracker. Even if it is an error in your code, you will often get a response from the maintainers more quickly than if you posted a question to a website such as stackoverflow.com.

CI System and Unit Tests

Qt has an extensive set of automated unit tests which are run by the Continuous Integration (CI) system (2). You can also run them yourself. When a bug in Qt is fixed, a unit test is usually written or updated to check for the bug and prevent it from coming back in the future. The tests can also be a useful resource for showing behavior of Qt classes that may not be obvious from the documentation and code examples.

Woboq

There is a useful online code browser (3) website that allows you to look at the Qt source code. It features semantic highlighting and contextual tooltips that show you usage and cross references. It can be an effective way to browse the source code of Qt itself without needing to have a local copy of it on your computer.

RTFM

When using a Qt class for the first time, it is worth spending the effort to read the documentation in full. If you fail to do this, you may overlook some convenient features or less obvious behavior. Asking basic questions on how to use a Qt class on mailing lists or forums is considered bad etiquette and you may not always receive accurate advice.

Know C++

Having a good general understanding of C++ is key to using Qt effectively. This includes the standard library (e.g. STL) and recent language features introduced in the C++11 and C++14 standards. That being said, you don't need to be an expert on all aspects of C++, but learning more about the language will make you a better Qt developer.

Don't Skimp on Hardware

Desktop computers have continued to improve in performance and available memory and storage capacity. If you develop on an older, slower machine you will spend a significant part of your day just waiting for your code to compile. Investing in a faster computer will pay off again and again in improved productivity. Be sure to take advantage of the parallel cores available on modern CPUs by using suitable options to your build system (e.g. use an appropriate -j option when using GNU make or consider using jom as a replacement for nmake).

Learn Your Tools

Take the time to learn the features of your development tools, whether it is the Qt Creator IDE, your favorite text editor or debugger. The typical IDE has many features that can improve your productivity and code quality. A few examples are:

advanced search and browsing features

integration with debuggers

integration with version control systems (e.g. git)

deployment and debugging to a remote embedded system

tools for profiling performance and analyzing memory usage and resource leaks

Third-Party Libraries

While Qt provides a lot of functionality, there are even more third party libraries available to extend it in various ways The #inqlude Qt Library Archive (4) is a website providing a comprehensive listing of third-party libraries for Qt developers. At the time of writing it had 192 libraries listed. I would caution you, however, to review the licensing of any third-party code to make sure it is compatible with your project and organization.

Bookmark the site and keep it in mind when you need additional functionality, so you don't reinvent the wheel when someone may have already done the work for you.

Summary

I hope you found this blog post useful and are able to incorporate some of these tips in your daily Qt development work.

Once again, I would like to thank the ICS development team for providing the tips and tricks presented here.

References