Mixing Juce and Qt

Hello Forum, I am building a graphics+audio application.

  1. I need advanced 2D graphics and the ability to render graphics to print and pdfs.
    2 I need to load, play and visually display audio files

I would like to use QT for all the graphics, printing and pdf export functionalities but I want to use Juce for audio playback, wave form drawing and scrolling, etc. How can I combine a Juce waveform view and a QT graphics view in the same application window? Is it even possible?

Regards,

Mariu

It’s certainly possible, but incredibly difficult (obviously).

The first obstacle is merging the build systems. Qt integrates well with CMake, so we’ll use that. You now need to build CMake modules for all the JUCE modules you need and get them all working together in such a way that there’s no symbol conflicts.

Once you have that working you’ll need to build an adapter QWidget which can act as a ComponentPeer to allow JUCE Component objects to talk to Qt, and most likely a LowLevelGraphicsContext which can draw to a QWidget surface via JUCE’s LowLevelGraphicsContext.

You’d probably be best off using one of the other. Qt provides a whole host of audio-related facilities and many major apps are written with it (Ableton Live comes to mind).

3 Likes

Sorry to chime in, but Ableton Live is not written with Qt.

They do use something from Qt, just check the Windows installation folder, it has Qt5Core.dll, Qt5Gui.dll etc. But it’s a safe bet they don’t use anything from Qt for audio. :wink:

You could write all your audio functionality as a DLL or static library and link to that from Qt. Just make a basic C API that wraps everything. This worked wonderfully with quite a few different projects of mine, including ReactNative iOS & Android and a python app. I’m sure Qt would be no different — it would be just like using any external library.

I have done that a lot — also works with pretty much any other system as well. A bit more of a pain to develop & test, but it’s probably the simplest answer, and there’s no messy merging of Qt and JUCE. Just a regular Qt app with a library.

2 Likes

I don’t think any of this would be necessary, since they said they wouldn’t be using any of the JUCE GUI functionality…

If they just want the audio bits, it’s a lot simpler to just write that as a DLL or static library and link to it from a regular Qt app. I’ve done this before and it works great.

1 Like

Additionally to the said, I would avoid mixing the drawing of both, since this is a crucial point for sudden performance problems, when the two graphics backends need to synchronise.
I would rather access the audio float arrays for displaying and write Qt rendering code.

All warnings and precautions about multi threading and not blocking the audio thread apply.

Thanks for the reply. That does sound complicated to me. Too bad Juce doesn’t print graphics and export pdfs.

They use Qt for display rendering on Push. That’s why the Qt dlls are present in the Ableton folder. More details here:

4 Likes

I am using Qt for UI. Just be sure to disable the web browser and any un-needed features from juce_gui_basics and juce_gui_extra when composing your project in the projucer. It took me some fiddling as I am a noob, but I got it working fine now.

3 Likes

Hi ivofx,

Would you be able to give a little more detail about your approach please? Did you follow jonathonracz’s approach (from the top of this thread) or something different?

Any pointers gratefully received!

late but relevant:

1 Like