Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

Creating Labview-looking plumbing diagrams



  • Hello,

    I am doing a Qt GUI to control a scientific instrument made of pumps, electro-valves, flow- or pressure-meters, and a lot of tubing in-between.

    I currently use standard Qt Widgets to control each device (e.g. QRadioButton to control/view valve on/off state, QSpinBox to control/view pump's speed), placed in QGroupBox.

    It works fine but it is not very user-friendly, it is hard to figure out that this QGroupBox refers to the main downstream pump controls, that this QRadioButton controls the water dispenser placed just after it, etc.

    I would like to make a graphical plumbing diagram with interactive controls on it. I am not familiar with Labview, but I saw GUI just like what I want to do. For example:
    alt text
    alt text
    I would like to be able to create custom shapes (like the valves of the 2 diagrams above) which should be clickable (thus changing their state) and editable (e.g. color change when their state changes).

    I know I could technically do that with a QPainter, but:

    • As far as I know there is no GUI to draw custom shapes, so even something as simple as a valve shape would be tedious to do.
    • Connecting shapes with "tubing" shapes will be also painful.
    • It would be fairly impossible to correctly place Qt standard shapes using QtDesigner, as the shapes made with QPainter would not be yet visible.
    • Manually set up everything is somehow possible with a lot of time, but any consequent change in the diagram (e.g. adding a valve and another liquid input) will force to re-do the whole process...

    I could also create custom widgets, but the "tubing connection" problem remains...

    Any idea about how to do that, the Qt-way ?
    Thanks.



  • @Blacksad

    It may not be an easy and quick-to-implement task, but it's definitely possible.

    @Blacksad said in Creating Labview-looking plumbing diagrams:

    As far as I know there is no GUI to draw custom shapes, so even something as simple as a valve shape would be tedious to do.

    There is no GUI, but you can draw nearly anything using basic shape subclasses and QPainter.

    @Blacksad said in Creating Labview-looking plumbing diagrams:

    Connecting shapes with "tubing" shapes will be also painful.

    Have a look at this example:
    https://doc.qt.io/qt-5/qtwidgets-graphicsview-diagramscene-example.html
    (Especially the auto-connection between objects) Instead of a simple line with arrow, you could use your "tube"-painter and just draw from center to center of next item.
    Another interesting example:
    https://doc.qt.io/qt-5/qtwidgets-graphicsview-dragdroprobot-example.html

    @Blacksad said in Creating Labview-looking plumbing diagrams:

    It would be fairly impossible to correctly place Qt standard shapes using QtDesigner, as the shapes made with QPainter would not be yet visible.

    You dont need to place shapes / widgets in QtDesigner. Everything can be added using code. Code is even more powerful than the QtDesigner.
    There is also Widget Promotion. You can replace standard Qt class widgets, you've placed in QtDesigner with your custom ones.

    @Blacksad said in Creating Labview-looking plumbing diagrams:

    Manually set up everything is somehow possible with a lot of time, but any consequent change in the diagram (e.g. adding a valve and another liquid input) will force to re-do the whole process...

    If you keep everything variable (maybe with a build-in editor to add valves or make new tube connection at runtime), you can add / take widgets from your process chain like you want.

    Definitely possible, but takes some time to plan and implement properly.



  • Thank you for your detailed explanations.
    I suspected there was no quick and easy way to do this with Qt, but now I know were to start.


Log in to reply