Hello,
I checked yesterday before sleep but didn't reply due to fatigue.
So...
QListView allows You not only to display images the way I showed in example, it can also display grid, between each "image". Think of it as n*m matrix, or spreadsheet, it's not exactly that way, but my point here is that You can span grids. And that way you can cheat displaying connection between in/out gates. But that would require a lot of tweaking and is probably not the way to go. (Change listView to tableView in example and set same model to see the difference, maybe table is what You want after all ).
Alternatively You could subclass one of the widget, that looks closest to Your desired widget that "holds" all the gates, then reimplement paint function, and paint image yourself. Prepare png for gates keeping in mind that in/out for each gates should be in the same position for each gate type. Then simply copy png onto screen.
But the problem is connection between gates. So what You could do is to implement A Star (A*) algorithm (path finding) and firstly copy all gates onto screen (for A* mark this area as blocked, in row manner ), then mark output of the gate as START for A*, and proper input of another gate as END for A*. How to find position of out/in of gates? As stated before prepare accordingly png so those place will be at fixed position + png offset. Lines could be painted on anothe QPixmap so if there is a need to modification You could implement that as well (simply deleting old connection grid, and repainting new one). That way You could draw a really complex gates, not only simple one. Again that is probably not what you want due to complexity, and I assume that you have predefined png for connections as well.
Then you could use QGraphicsView, see /qt/examples/graphicsview, especially qt/examples/graphicsview/diagramscene, for examples. I didn't do much work with this, so I can't point you any useful examples that You could use, but last example should give You general idea how to paint these pngs.
Also I assume that program only draw gates, and don't allow any modification/correction, so, as stated before You could pull it off with QListView but I think easiest way would be going with QGraphicsView, because that allow You scrolling, zooming, etc...
Best luck with you project
EDIT: I forget about QPainter, that can draw shapes, lines, etc.. So you could place in table at col 0 row 1-2 gate png, at col 1 row 1-2 span and draw connections, and at col 2 row 1-2 gates pngs.
Bookmarks