Best layout for a virtual pinboard?
-
I've built a PyQt desktop app and I've had a request to add a window that would function as a virtual pinboard.
DON'T WORRY, I'M NOT ASKING SOMEONE TO BUILD IT FOR ME- just asking for advice about the best general approach.
There would be rows and columns, and in them, virtual 'cards'. Each cell could hold any number of cards- 0, 1, or more than 1. Cards could also, potentially, span more than one cell. In a cell with many cards, they might get displayed overlapping, one card partially behind another.
Each card would consist of multiple widgets in their own little frame, e.g. each single card might have a QLabel at the top, a QPictureBox in the middle and a QLabel at the bottom.
The dream behaviour would be that the cards would be draggable- a user could pick up a card and move it to a different cell, which would then trigger code updating the underlying database. This is the behaviour I see online in places like GitLab and Trello for example.
It would also be necessary to be able to display in the GUI a link (drawn line) between two cards to indicate that they are connected.
My initial two thoughts are:
-
Do the entire thing as one giant QPictureBox and draw everything manually; more control and flexibility, but how to handle drag-and-drop?
-
Try to enhance a QGridLayout to support this somehow
-
Look at using a QGraphicsScene, which I've not used before
So my very broad question is - how do you think I could do this?
Which is the best approach, do you think? Are there any other layout options or special widgets I might not be aware of? Or any shared library where somebody's already tackled this?
Thanks in advance for any opinions
-
-
@donquibeats said in Best layout for a virtual pinboard?:
It would also be necessary to be able to display in the GUI a link (drawn line) between two cards to indicate that they are connected.
Once you say this, my thought is move to
QGraphicsScene
. Drag & drop is still available there. It might be possible to do line drawing if you stick to widgets, but I think it gets tricky. Note that there is a QGraphicsWidget Class, so you can still use widget functionality to build your complex widgets as such and place them on the graphics scene without resorting to abandoning that. You will have to deal with your own rows/columns/grids, but since you want to overlap and span you would probably exceed the capabilities of aQGridLayout
anyway.Unless other experts recommend you to stick with widgets/positioning/layouts only....
-
That's great, thanks for the response.
Yes, it looks like QGraphicsScene is the way to go- I'll have a look.