qt5

This tool helps with finding Qt5 tools and libraries, and also provides syntactic sugar for using Qt5 tools.

The following snippet illustrates the tool usage:

def options(opt):
        opt.load('compiler_cxx qt5')

def configure(conf):
        conf.load('compiler_cxx qt5')

def build(bld):
        bld(
                features = 'qt5 cxx cxxprogram',
                uselib   = 'QT5CORE QT5GUI QT5OPENGL QT5SVG',
                source   = 'main.cpp textures.qrc aboutDialog.ui',
                target   = 'window',
        )

Here, the UI description and resource files will be processed to generate code.

Usage

Load the “qt5” tool.

You also need to edit your sources accordingly:

  • the normal way of doing things is to have your C++ files include the .moc file. This is regarded as the best practice (and provides much faster compilations). It also implies that the include paths have beenset properly.

  • to have the include paths added automatically, use the following:

    from waflib.TaskGen import feature, before_method, after_method
    @feature('cxx')
    @after_method('process_source')
    @before_method('apply_incpaths')
    def add_includes_paths(self):
       incs = set(self.to_list(getattr(self, 'includes', '')))
       for x in self.compiled_tasks:
           incs.add(x.inputs[0].parent.path_from(self.path))
       self.includes = sorted(incs)
    

Note: another tool provides Qt processing that does not require .moc includes, see ‘playground/slow_qt/’.

A few options (–qt{dir,bin,…}) and environment variables (QT5_{ROOT,DIR,MOC,UIC,XCOMPILE}) allow finer tuning of the tool, tool path selection, etc; please read the source for more info.

The detection uses pkg-config on Linux by default. To force static library detection use: QT5_XCOMPILE=1 QT5_FORCE_STATIC=1 waf configure

Features defined in this module: