简体   繁体   中英

Qt4 modular synth editing widget

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:

英根
(source: drobilla.net )

纯数据

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

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.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM