Custom QQuickItem vs. Widgets QGraphicsView for music notation
I'm working on a hobby project to create a music notation editor (similar to this). I've started on the UI using QML (since it seems to be the main direction in which Qt is moving) and so far, I really enjoy the productivity gain. However, I'm about to start implementing the actual music notation piece and I'm wondering if QtQuick is the right tool for the job. Some features I'm looking for are:
- Using special fonts to render the musical symbols
- Interacting with the notation using keyboard and mouse
- Being able to layout the notation in various ways (1 page wide, 2 pages wide, using horizontal scrolling instead of pages, etc.)
- Printing support
I'd prefer to implement all of the rendering and interaction logic in C++ to avoid having to wrap up my entire data model in a way that can be exposed to QML. I've looked into implementing a custom
QQuickItemand using the scene graph APIs, but I'm not clear if this would be the best tool for the job (seems overly complex for my use case, how do I handle user interactions and text/glyph rendering). So for my question: is
QGraphicsViewsimply a better fit for my use case? I'd hate to abandon the productivity QML provides for the other parts of the app, but I assume I could still use it inside a Widgets-based app. Or should I just use a custom
QQuickItem(or another option I might be missing)?
Its hard to say if QGraphicsView would be "better". It certainly would be good for it.
Providing panning and zoom.
But so would/could QML but will require some more boilerplate code to surface the data from the c++ back end.
It is possible to mix QML and Widgets with
but again, it will need access to the model somehow.
A custom QQuickItem could work but making the notation using scene graph api seems a bit
hardcore. (but efficient)
Maybe this can help you choose
Thanks for the input! I think I'm going to go with
QGraphicsViewfor the notation and use
QQuickWidgetsthroughout the other pieces of the UI that don't need access to the entire model. I'm hoping that won't be too complicated and will give me the best of both worlds. But I do wonder: is there a specific piece of Qt Quick that's supposed to a "replacement" for
QGraphicsView? It seems like the scene graph is a bit too low level, but it's also the only way to gain a lot of control and keep things mostly on the C++ side. It would be nice if the built-in QML elements are exposed via a C++ API at some point.