Qt World Summit: Submit your Presentation

Some kind of drag'n'drop and "linking" in a GUI

  • Hello everyone,

    Sorry for my bad english, I'm not a native... bla bla bla you know the end ;)

    I am practicing my Qt skills (with Python) and I try to make an easy electrical software. By electrical software, in reality I just want to be able to draw simple objects (like resistors) and connect them by clicking on the edge of one and on the edge of another one.

    Well nothing too complicated for someone familiar with Qt I guess... This is what it could look like : https://www.edrawsoft.com/fr/images/electrial-drawing-software.png (just way simpler, I don't want to make a real program, this is just practising for fun and I have already made some other softwares but nothing with this kind of behaviour).

    Now that you know everything, I am not asking the full source code for an already made software (I will still thank you if you can provide that). I would like to know what is the :
    1 - easiest
    2 - good
    3 - best
    way to do it ?

    What I think (but it is a pain in the...) : Use a QPainter and draw the resistor each time the user click on the resitor icon. This would be an object and we should be able to select it and move it in the QPainter (the object would be redrawn each time its position changes). For the link between them it would be a simple line drawn between the extremity of the first object and the extremity of the second object.

    That sounds just like an absolute mess, I can't believe this is how electrical software handle their drawings/movements/connections/... But I really don't know how this is usually done... Anyone have an idea ?

    edit : I found QElectroTech, for the moment, and it seems that they use a QPainter...

    Thanks :)

  • Lifetime Qt Champion

    Hi and welcome to devnet,

    You might want to check the Elastic Nodes Example.

    The Graphics View Framework will be of interest as it provides a lot of the underlying mechanisms like movable objects, easy to draw image objects, etc.

  • Just to know if someone else have an idea (not that the previous one does not please me but I just want to know if someone else can have another type of answer).


  • Lifetime Qt Champion

Log in to reply