7

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.

NG_
  • 6,895
  • 7
  • 45
  • 67
mhag
  • 85
  • 2
  • 6
  • I haven't figured it out yet, but figures that after more than a few hours of research I find a better solution just after I ask this site. QGraphicsView seems promising. – mhag Aug 12 '14 at 19:43
  • Have you tried QML? It's part of the Qt-Framework and is a Javascript-based language made especially for UI-Tasks/Design, which can easily be accessed from C++. – Miterion Aug 12 '14 at 20:00

2 Answers2

6

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.

Honest Abe
  • 8,430
  • 4
  • 49
  • 64
Nejat
  • 31,784
  • 12
  • 106
  • 138
  • Thanks, I found that very helpful. The documentation I had just found didn't do a great job explaining it; the example helped a lot. I'll let you know how it goes. Do you think I'll be able 'snap' objects into place? I don't need that functionality, but I'm looking into it for a neater appearance. – mhag Aug 13 '14 at 13:13
1

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/

adnan kamili
  • 8,967
  • 7
  • 65
  • 125