[Qt-creator] https://wiki.qt.io/ModelEditor

Jochen Becher jochen_becher at gmx.de
Tue Feb 16 20:35:23 CET 2016


Hi Klaus,

most of the plugin's features are implemented in libs/modelinglib,
namespace "qmt". 

Use qmt::ProjectController to load a qmodel file. The loaded
qmt::Project references a qmt::MPackage as the root to the model. 

Many use cases can be implemented using the visitor pattern on the
model (see qmt::MConstVisitor and qmt::MVisitor). 

If you want to modify the model you must use qmt::ModelController.
Before you change a model element you must call
qmt::ModelController::startUpdateObject() or
qmt::ModelController::startUpdateRelation(). After changing the element
you must call qmt::ModelController::finishUpdateObject() /
qmt::ModelController::finishUpdateRelation(). There are also extra
methods for inserting or deleting elements from the model. Never change
the model without calling these functions from the controller. (There
is qmt::DiagramController which implements the same for diagrams).

Look into qmt::DocumentController. This is the master class which
creates and connects all the other controllers.

Unfortunately the ModelEditor plugin is not (yet) made to be extended.
There are no well-defined extension points and no factories are used
which would allow using extended classes. If you want to extend the
plugin or hook in another plugin you have to change the source code of
ModelEditor plugin itself. 

You may extend ModelEditor::Internal::ActionHandler to add menu items
to the global menu (e.g. create a new submenu in "Tools"). Adding
context menu items for elements on a diagram is even harder. Currently
it is hard coded in qmt::ObjectItem::contextMenuEvent() and derived
classes.

If you send me a little more details about what extension points you
need I will have a look on it.

Hope this helps a little bit.

Regards, Jochen


Am Dienstag, den 16.02.2016, 19:21 +0100 schrieb Klaus Reckefuss:
> I want to "misuse" the new modelplugin for my own mopdel system and
> generate c++ code from it.
> 
> So i need the name of the classsystem which hold the model and how to
> fill it from a given qmodel file.
> And i want to make on the displayed model on right mouse button a
> window
> control to generate code.
> Where in the given model i can integrate that?
> 
> 
> _______________________________________________
> Qt-creator mailing list
> Qt-creator at qt-project.org
> http://lists.qt-project.org/mailman/listinfo/qt-creator



More information about the Qt-creator mailing list