PDA

View Full Version : Toolbox Architecture Question



jonks
8th July 2009, 16:55
Hi

I'm fairly new to Qt. I've been messing around and having fun with QGraphics* objects for a couple of months. I now want to start doing some "standard" GUI work, but I don't know how to do this efficiently.

What I'm basically trying to create is a main work area (QGraphicsScene/view) and a docked "toolbox". The toolbox contains shapes that can be dragged and dropped into the QGraphicsScene.
The toolbox will contain more shapes than can fit into the toolbox. So I need a scroll area inside the toolbox.

(Very standard + easy concept)

I've gone off the rails because I suspect that there is an easy way to do this - Qt keeps surprising me with all the things that can be done in 4 or 5 lines of code, so now I have a bad case of "analysis paralysis". I'm spending a long time looking for those elusive 4-5 lines that will make my live so much easier, but I don't know where to look, or what to look for.

From reading the docs, the architecture of the toolbox I think I need is this:

QDockWidget

contains QScrollArea

contains a QWidget (what type of QWidget should I use?)

containing 1 child QWidget for each shape



Does this look right to you?
Is there is a shortcut to obtaining this layout? Perhaps there is a specialized set of classes for this type of thing ("QImageListView" "QWidgetListView"?? - in my dreams!)

Thanks for any pointers

wysota
8th July 2009, 17:48
Your concept is fine. You may substitute the part starting with QScrollArea with a QListView set into icon mode if you want. You'd probably want to manipulate the palette and frames to make it look more like a toolbox although the default look should be fine as well.