I'm working on making a editable flowchart and I'm having a lot of issues conceptually with Qt. I've tried many different ways of implementing classes ranging from QTreeWidget
, QTableWidget
, and using just a bunch of easy QPushButtons
.
Ideally I'd like to have a setup where I can right click on each piece of the flow and edit it. In addition to having a drag and drop feature to rearrange the objects in the flow. Trying to find a class/group of classes I can use together to achieve this has been a struggle.
What classes would work the best for this application; specifically GUI classes? The actual content of the editing shouldn't be relevant to the GUI I'm looking for suggestion or methods I may have missed. Aside from the functionality, it doesn't have to look that fancy; rectangles and straight lines would suffice.
So far I know how to use and implement contextMenus, and regular Menus to contain all the actions I'll need, but now I need to find a model and view that is compatible with my plans and can hold the data. (That's the easy part; I have my own self made class for that)
I'm new to Qt and C++. (Not new to object orientated programming, just the different syntax and API.)
The sort of flowchart I'm looking for is this:
Or you can just google 'flowchart' (Taken out of context and I don't need colors)
Thanks in advance. I haven't found a solution that I understand yet; or that uses Qt hardcoding. Any suggestions are appreciated.
There is a Diagram Scene Example which uses the Graphics View framework to make flowchart diagrams. It is an application in which you can add flowchart shapes and text and connect the shapes by arrows. The shapes, arrows, and text can be given different colors, and it is possible to change the font, style, and underline of the text.
You can take a look at the code and see how to create custom graphics items and handle mouse events and movement of items.
You can use QCustomPlot library. It has support for rectangle and other shaped items and lines etc. It will just make your work lot easier.
来源:https://stackoverflow.com/questions/25272157/making-an-editable-flowchart-in-qt-c