Question

I'm about to start writing a GUI for a modular synthesis app (like Alsa Modular Synth, Pure Data, Ingen) that will be used for patch (sound) editing.

What I need to do is something like this:

Ingen
(source: drobilla.net)

Pure Data

hallseymrk1?
(source: mcgill.ca)

So, basically, it's an area where I can draw some rectangles (boxes) that represent synth modules with input and output ports that I can connect with wires.

The problem is that I can't figure out how two create a widget for the editing area: Using a simple 2D drawing context where I draw the boxes manually seems to be the only logical way to do this, but doing this I loose all the great event management that qt gives me.

I'm wondering if there's the possibility of creating a custom layout that simply takes coordinates of created "boxes" and put them on the screen, so that I implement the boxes as subclasses of QWidget (and reusing qt's event handling system) and I add them to the window as I do usually.

Or maybe there's a better way?

Thank you

Was it helpful?

Solution

Take a look at QGraphicsScene and QGraphicsView. This way you will be able to create a scene filled with items. Each item can receive mouse events and you can manually paint it.

OTHER TIPS

You can create a custom layout class that inherits from QLayout and overload the add(QWidget* w) function with the coordinates.

Personnally I'm using QGraphicsView and QGraphicsScene. You can handle some events (as mouse event) and easily find your QGraphicsItem.

Have a look at Gephex sourcecode on http://www.gephex.org/download.php

they have already built such a widget for Qt, although might be a bit old code (QT3) and application specific.

ciao

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top