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. The list of libraries to be requested to pkg-config is formulated by scanning in the QTLIBS directory (that can be passed via –qtlibs or by setting the environment variable QT5_LIBDIR otherwise is derived by querying qmake for QT_INSTALL_LIBS directory) for shared/static libraries present. Alternatively the list of libraries to be requested via pkg-config can be set using the qt5_vars attribute, ie:
conf.qt5_vars = [‘Qt5Core’, ‘Qt5Gui’, ‘Qt5Widgets’, ‘Qt5Test’];
This can speed up configuration phase if needed libraries are known beforehand, can improve detection on systems with a sparse QT5 libraries installation (ie. NIX) and can improve detection of some header-only Qt modules (ie. Qt5UiPlugin).
To force static library detection use: QT5_XCOMPILE=1 QT5_FORCE_STATIC=1 waf configure
Features defined in this module: