Use libcamera with Qt
Qt is a popular application framework and GUI toolkit. rpicam-apps includes an option to use Qt for a camera preview window.
Unfortunately, Qt defines certain symbols (such as slot and emit) as macros in the global namespace. This causes errors when including libcamera files. The problem is common to all platforms that use both Qt and libcamera. Try the following workarounds to avoid these errors:
-
List
libcamerainclude files, or files that includelibcamerafiles (such asrpicam-appsfiles), before any Qt header files whenever possible. -
If you do need to mix your Qt application files with
libcameraincludes, replacesignals:withQ_SIGNALS:,slots:withQ_SLOTS:,emitwithQ_EMITandforeachwithQ_FOREACH. -
Add the following at the top of any
libcamerainclude files:#undef signals #undef slots #undef emit #undef foreach -
If your project uses
qmake, addCONFIG += no_keywordsto the project file. -
If your project uses
cmake, addSET(QT_NO_KEYWORDS ON).