[libcamera-devel] Trying to use libcamera with Qt

Jason H jhihn at gmx.com
Fri Mar 26 20:17:14 CET 2021



> Sent: Friday, March 26, 2021 at 11:41 AM
> From: "Laurent Pinchart" <laurent.pinchart at ideasonboard.com>
> To: "Jason H" <jhihn at gmx.com>
> Cc: libcamera-devel at lists.libcamera.org
> Subject: Re: [libcamera-devel] Trying to use libcamera with Qt
>
> Hi Jason,
>
> On Fri, Mar 26, 2021 at 03:01:10PM +0100, Jason H wrote:
> >
> > > > So it looks I was wrong about Q_OBJECT being the gatekeeper. Once I
> > > > config no_keywords in Qt, it works. It's a shame I have to do that for
> > > > one variable name.
> > >
> > > Sorry about that :-( We do the same in our qcam test application. Qt
> > > defines 'signals' and 'slots' as keywords by default, but that can
> > > indeed clash with third-party code. Using Q_SIGNALS and Q_SLOTS instead
> > > with no_keywords may not look very native, but hopefully it will be an
> > > acceptable solution for you.
> >
> > Well I'm glad there's a way to get it to work. But this happens at project
> > scope, meaning that EVERY QObject class definition has to be altered.
> > Meaning that that one line of code changes about 15 classes, 30 lines
> > in my project because it's Q_SIGNALS and Q_SLOTS.
>
> As the no_keywords qmake option turns into a QT_NO_KEYWORDS macro, could
> the latter be used instead, at file scope ?

Inspired by your suggestion, I played around, and came up with:

// to be added at top of libcamera/signal.h, before namespace
#ifdef QT_CORE_LIB
#undef slots
#undef emit
#endif

Which seemed to make Qt able to compile ok. QT_CORE_LIB is defined by the Qt
Makefile, unless QT -= core is used int he project, which would be kinda
crazy to do.





More information about the libcamera-devel mailing list