Connect CustomObjects with a line between them
-
Hi, I'm very new to GUI programming. I'm scratching my ahead around this one:
I want a button so that when its pressed gets the next two clicked objects and draw a line between them.
What I don't know:- Once the button is pressed getting the two clicked objects
- Drawing a Line and Connecting both objects so that if I move one the line will follow it (stretch, contract, break, etc)
Basically, like an ER Diagram, since the objects here are all rectangles.
-
Hi,
Sounds like an "edit mode" button. Can you give a bit more details about what you are currently using ? Is it the graphics view framework ? Widgets ? QtQuick ?
-
Hi,
Sounds like an "edit mode" button. Can you give a bit more details about what you are currently using ? Is it the graphics view framework ? Widgets ? QtQuick ?
@SGaist Sure, thanks for the reply! I'm creating a mainwindow using QGraphicsView to display movable objects which are custom QGraphicsItems. I want the user to be able to freely connect/disconnect these objects similar to the way an ER Diagram is made using MySQL workbench.
-
You should take a look at the Elastic Nodes example.
As for the click handling you might want to use an event filter that will act in "edit mode" to catch the two next click when the mode is activated.
-
You should take a look at the Elastic Nodes example.
As for the click handling you might want to use an event filter that will act in "edit mode" to catch the two next click when the mode is activated.
-
Nothing special about it. It's a bit like the "text/preview" you have with the markdown editor on e.g. Gitlab. In this case you have your application running "normally" and when you click on some button/menu item, you activate some additional layer that will handle the next two items you click.
-
Hi
Just as a note
This sample also allows connected objects
http://doc.qt.io/qt-5/qtwidgets-graphicsview-diagramscene-example.html
and can provide good basic if you make anything like a diagram editor.