Common Vision Blox 15.0
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Events Friends Modules Pages
Image Display in C++ Using Qt/QML

To build modern and responsive graphical user interfaces (GUIs) for CVB applications, the Qt framework provides a flexible and powerful foundation. Whether you're working with classic Qt Widgets or a QML-based interface, CVB offers native support for both through its Cvb::UI module. This section explains how to integrate CVB image display functionality into your Qt or QML application using C++.

Prerequisites

Before starting, ensure that you have installed Common Vision Blox (CVB) and CMake, and that you've successfully built a basic CVB application, as described in Getting Started with C++.

To integrate Qt/QML into your CVB C++ project, you will also need to download and install Qt5.

Attention
CVB is only compatible with Qt versions between 5.9 and 5.14.2 (inclusive). Please also ensure that your Qt version matches both your compiler and your operating system architecture (e.g., 64-bit MSVC 2017).

Building a Sample Application with CMake and Qt/QML

If you already have a working CMakeLists.txt for your CVB application, you only need to add a few lines to enable Qt/QML support.

To locate the necessary Qt components, use find_package:

find_package(QtWidgets REQUIRED)
find_package(Qt5OpenGL REQUIRED)
find_package(Qt5Quick REQUIRED) # Only if using QML

Then, link the required Qt modules and CVB libraries. To enable the integration between CVB and Qt, also link against CVB::CvbUI.

target_link_libraries(${PROJECT_NAME}
CVB::Cvb
CVB::CvbUI
Qt5::Widgets
Qt5::OpenGL
Qt5::Quick
)
Note
Make sure that CMAKE_PREFIX_PATH is correctly set (e.g., to C:/Qt/Qt5.14.2/5.14.2/msvc2017_64/lib/cmake) so that CMake can locate your Qt installation. Additionally, add the Qt bin directory to your system PATH environment variable to ensure the Qt runtime DLLs can be found when running your application.

For more in-depth instructions and troubleshooting, refer to the post Getting Started with CVB++, QML, CMake in the CVB User Forum.

CVB User Interface

To simplify the integration of Qt with CVB, the library provides the Cvb::UI module. It allows you to easily display CVB images within Qt applications using the Cvb::UI::ImageView widget.

If you are working with a QML-based user interface, refer to the Cvb::UI::Quick module, which provides QML-compatible components.

For example applications, see the next section.

Example Programs

Your CVB installation includes several example programs demonstrating the integration of CVB with Qt and QML. These examples include complete C++ source code and a working CMakeLists.txt. They are located under %CVB%Tutorial (Windows) or $CVB/tutorial (Linux). Look for examples starting with Qt or Qml in their names:

QtImageDisplay
QtStreamDisplay
QtStatisticsDisplay

QmlImageDisplay
QmlGevServer

and more...