This is a follow-up question of Making an editable flowchart in Qt/C++.
I want to add a QGraphicsItem
to a QGraphicsGridLayout
in a way that the item takes up its own spot in the grid and then automatically centers in its 'cell'.
I am using QGraphicsView
and QGraphicsScene
, and drag-and-drop to any location works, but it's looking messy, and could prove to be problematic in future development.
What do I have to do so the item snaps to the grid and centers in its cell?
PS: I have taken a look at http://qt-project.org/doc/qt-4.8/graphicsview-basicgraphicslayouts.html as an example but this didn't help me to solve my problem.
Also, it'd be ideal to have this layout and its data be savable to a text file, etc. I'm assuming a 2D array would be the best way to do this. Should I somehow make the QGraphicsGridLayout based on that array, or is there a better solution?