Qt4 模块化合成器编辑小部件

发布于 2024-08-06 04:52:33 字数 1141 浏览 3 评论 0原文

我即将开始为模块化合成应用程序(如 Alsa Modular Synth、Pure Data、Ingen)编写一个 GUI,该应用程序将用于补丁(声音)编辑。

我需要做的是这样的:

Ingen
(来源:drobilla.net

纯数据

hallseymrk1?
(来源:mcgill.ca)< /sub>

所以,基本上,这是一个我可以绘制一些矩形(框)的区域,这些矩形(框)代表带有输入和输出端口的合成器模块,我可以用电线连接这些端口。

问题是我无法弄清楚如何为编辑区域创建一个小部件:使用一个简单的 2D 绘图上下文(其中我手动绘制框)似乎是执行此操作的唯一合乎逻辑的方法,但这样做我失去了所有qt 给我带来了很棒的事件管理。

我想知道是否有可能创建一个自定义布局,只需获取创建的“盒子”的坐标并将它们放在屏幕上,以便我将这些盒子实现为 QWidget 的子类(并重用 qt 的事件处理系统),然后我添加像我平常一样把它们放在窗户上。

或者也许有更好的方法?

谢谢

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

懒的傷心 2024-08-13 04:52:33

看一下 QGraphicsScene 和 QGraphicsView。
这样您就可以创建一个充满物品的场景。
每个项目都可以接收鼠标事件,并且您可以手动绘制它。

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.

渔村楼浪 2024-08-13 04:52:33

您可以创建一个继承自 QLayout 的自定义布局类,并使用坐标重载 add(QWidget* w) 函数。

我个人使用的是 QGraphicsView 和 QGraphicsScene。您可以处理一些事件(如鼠标事件)并轻松找到您的 QGraphicsItem。

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.

怂人 2024-08-13 04:52:33

查看 http://www.gephex.org/download.php 上的 Gephex 源代码

他们已经为 Qt 构建了这样的小部件,尽管代码可能有点旧(QT3)并且特定于应用程序。

再见

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文