For ports that are part of Qt itself, see Section 17.77, “qt-dist”.
The Ports Collection provides support for Qt 5 with
	USES+=qt:5.  Set USE_QT
	to the list of required Qt components (libraries, tools,
	plugins).
The Qt framework exports a number of variables which can be used by ports, some of them listed below:
QMAKE | Full path to qmake
		binary. | 
LRELEASE | Full path to lrelease
		utility. | 
MOC | Full path to moc. | 
RCC | Full path to rcc. | 
UIC | Full path to uic. | 
QT_INCDIR | Qt include directory. | 
QT_LIBDIR | Qt libraries path. | 
QT_PLUGINDIR | Qt plugins path. | 
Individual Qt tool and library dependencies must be
	specified in USE_QT.
	Every component can be suffixed with
	_build or _run, the
	suffix indicating whether the dependency on the component is
	at buildtime or runtime.  If unsuffixed, the component will be
	depended on at both build- and runtime.  Usually, library
	components are specified unsuffixed, tool components
	are mostly specified with the _build suffix
	and plugin components are specified with the
	_run suffix.  The most commonly used
	components are listed below (all available components are
	listed in _USE_QT_ALL, and
	_USE_QT5_ONLY in
	/usr/ports/Mk/Uses/qt.mk):
| Name | Description | 
|---|---|
3d | Qt3D module | 
assistant | Qt 5 documentation browser | 
canvas3d | Qt canvas3d module | 
charts | Qt 5 charts module | 
concurrent | Qt multi-threading module | 
connectivity | Qt connectivity (Bluetooth/NFC) module | 
core | Qt core non-graphical module | 
datavis3d | Qt 5 3D data visualization module | 
dbus | Qt D-Bus inter-process communication module | 
declarative | Qt declarative framework for dynamic user interfaces | 
designer | Qt 5 graphical user interface designer | 
diag | Tool for reporting diagnostic information about Qt and its environment | 
doc | Qt 5 documentation | 
examples | Qt 5 examples sourcecode | 
gamepad | Qt 5 Gamepad Module | 
graphicaleffects | Qt Quick graphical effects | 
gui | Qt graphical user interface module | 
help | Qt online help integration module | 
l10n | Qt localized messages | 
linguist | Qt 5 translation tool | 
location | Qt location module | 
multimedia | Qt audio, video, radio and camera support module | 
network | Qt network module | 
networkauth | Qt network auth module | 
opengl | Qt 5-compatible OpenGL support module | 
paths | Command line client to QStandardPaths | 
phonon4 | KDE multimedia framework | 
pixeltool | Qt 5 screen magnifier | 
plugininfo | Qt5 plugin metadata dumper | 
printsupport | Qt print support module | 
qdbus | Qt command-line interface to D-Bus | 
qdbusviewer | Qt 5 graphical interface to D-Bus | 
qdoc | Qt documentation generator | 
qdoc-data | QDoc configuration files | 
qev | Qt QWidget events introspection tool | 
qmake | Qt Makefile generator | 
quickcontrols | Set of controls for building complete interfaces in Qt Quick | 
quickcontrols2 | Set of controls for building complete interfaces in Qt Quick | 
remoteobjects | Qt5 SXCML module | 
script | Qt 4-compatible scripting module | 
scripttools | Qt Script additional components | 
scxml | Qt5 SXCML module | 
sensors | Qt sensors module | 
serialbus | Qt functions to access industrial bus systems | 
serialport | Qt functions to access serial ports | 
speech | Accessibilty features for Qt5 | 
sql | Qt SQL database integration module | 
sql-ibase | Qt InterBase/Firebird database plugin | 
sql-mysql | Qt MySQL database plugin | 
sql-odbc | Qt Open Database Connectivity plugin | 
sql-pgsql | Qt PostgreSQL database plugin | 
sql-sqlite2 | Qt SQLite 2 database plugin | 
sql-sqlite3 | Qt SQLite 3 database plugin | 
sql-tds | Qt TDS Database Connectivity database plugin | 
svg | Qt SVG support module | 
testlib | Qt unit testing module | 
uiplugin | Custom Qt widget plugin interface for Qt Designer | 
uitools | Qt Designer UI forms support module | 
virtualkeyboard | Qt 5 Virtual Keyboard Module | 
wayland | Qt5 wrapper for Wayland | 
webchannel | Qt 5 library for integration of C++/QML with HTML/js clients | 
webengine | Qt 5 library to render web content | 
webkit | QtWebKit with a more modern WebKit code base | 
websockets | Qt implementation of WebSocket protocol | 
websockets-qml | Qt implementation of WebSocket protocol (QML bindings) | 
webview | Qt component for displaying web content | 
widgets | Qt C++ widgets module | 
x11extras | Qt platform-specific features for X11-based systems | 
xml | Qt SAX and DOM implementations | 
xmlpatterns | Qt support for XPath, XQuery, XSLT and XML Schema | 
To determine the libraries an application
	depends on, run ldd on the main
	executable after a successful compilation.
| Name | Description | 
|---|---|
buildtools | build tools (moc,
		rcc), needed for almost every
		Qt application. | 
linguisttools | localization tools: lrelease,
		lupdate | 
qmake | Makefile generator/build utility | 
| Name | Description | 
|---|---|
imageformats | plugins for TGA, TIFF, and MNG image formats | 
In this example, the ported application uses the Qt 5
	  graphical user interface library, the Qt 5 core library,
	  all of the Qt 5 code generation tools and Qt 5's Makefile
	  generator.  Since the gui library
	  implies a dependency on the core library,
	  core does not need to be specified.
	  The Qt 5 code generation tools moc,
	  uic and rcc, as well
	  as the Makefile generator qmake are
	  only needed at buildtime, thus they are specified with the
	  _build suffix:
USES= qt:5 USE_QT= gui buildtools_build qmake_build
If the application provides a
	qmake project file
	(*.pro), define
	USES= qmake along with
	USE_QT.  USES= qmake
	already implies a build dependency on qmake, therefore the
	qmake component can be omitted from
	USE_QT.  Similar to CMake,
	qmake supports out-of-source
	builds, which can be enabled by specifying the
	outsource argument (see USES= qmake
	example).  Also see Table 6.16, “Possible Arguments for
	  USES= qmake”.
USES= qmake| Variable | Description | 
|---|---|
no_configure | Do not add the configure target.  This is
		implied by HAS_CONFIGURE=yes
		and GNU_CONFIGURE=yes.
		It is required when the build only needs the
		environment setup from
		USES= qmake, but otherwise runs
		qmake on its own. | 
no_env | Suppress modification of the configure and make
		environments.  It is only required when
		qmake is used to configure the
		software and the build fails to understand the
		environment setup by
		USES= qmake. | 
norecursive | Do not pass the -recursive
		argument to qmake. | 
outsource | Perform an out-of-source build. | 
qmake| Variable | Description | 
|---|---|
QMAKE_ARGS | Port specific qmake
		flags to be passed to the qmake
		binary. | 
QMAKE_ENV | Environment variables to be set for the
		qmake binary.   The default is
		${CONFIGURE_ENV}. | 
QMAKE_SOURCE_PATH | Path to qmake project files
		(.pro).  The default is
		${WRKSRC} if an
		out-of-source build is requested, empty
		otherwise. | 
When using USES= qmake, these
	settings are deployed:
CONFIGURE_ARGS+=	--with-qt-includes=${QT_INCDIR} \
			--with-qt-libraries=${QT_LIBDIR} \
			--with-extra-libs=${LOCALBASE}/lib \
			--with-extra-includes=${LOCALBASE}/include
CONFIGURE_ENV+=	QTDIR="${QT_PREFIX}" QMAKE="${QMAKE}" \
		MOC="${MOC}" RCC="${RCC}" UIC="${UIC}" \
		QMAKESPEC="${QMAKESPEC}"
PLIST_SUB+=	QT_INCDIR=${QT_INCDIR_REL} \
		QT_LIBDIR=${QT_LIBDIR_REL} \
		QT_PLUGINDIR=${QT_PLUGINDIR_REL}Some configure scripts do not support the arguments above.
	To suppress modification of CONFIGURE_ENV
	and CONFIGURE_ARGS, set
	USES= qmake:no_env.
USES= qmake ExampleThis snippet demonstrates the use of qmake for a Qt 5 port:
USES= qmake:outsource qt:5 USE_QT= buildtools_build
Qt applications are often written to be cross-platform and often X11/Unix is not the platform they are developed on, which in turn leads to certain loose ends, like:
Missing additional include
	      paths.  Many applications come with
	    system tray icon support, but neglect to look for
	    includes and/or libraries in the X11 directories.  To add
	    directories to qmake's
	    include and library search paths via the command
	    line, use:
QMAKE_ARGS+=	INCLUDEPATH+=${LOCALBASE}/include \
		LIBS+=-L${LOCALBASE}/libBogus installation paths.
	    Sometimes data such as icons or .desktop files are by
	    default installed into directories which are not scanned
	    by XDG-compatible applications.
	    editors/texmaker is
	    an example for this - look at
	    patch-texmaker.pro in the
	    files directory of that port for a
	    template on how to remedy this directly in the
	    qmake project file.
All FreeBSD documents are available for download at https://download.freebsd.org/ftp/doc/
Questions that are not answered by the
    documentation may be
    sent to <freebsd-questions@FreeBSD.org>.
    Send questions about this document to <freebsd-doc@FreeBSD.org>.