Making an editable flowchart in Qt/C++

半世苍凉 提交于 2019-12-04 13:46:04

问题


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.


回答1:


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.




回答2:


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.

http://www.qcustomplot.com/



来源:https://stackoverflow.com/questions/25272157/making-an-editable-flowchart-in-qt-c

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!