View Full Version : how to create something like widget box in qt designer
gregsan
18th July 2008, 12:45
Hi,
in our application called Orange (http://www.ailab.si/orange)we also have a set of widgets split into categories. We would like to have an interface to select these widgets which would be as similar as possible to Qt designer's Widget Box.
http://jimmy.fri.uni-lj.si/screen.png
Do you have any idea how would I do this?
Thanks in advance for any help.
Gregor
munna
18th July 2008, 13:26
Is this not a QToolBox
caduel
18th July 2008, 13:37
a QToolBox is like a QTabWidget, but the tabs are 'above each other'.
See the Qt widget gallery for an example.
This looks like a QTreeView to me.
Probably the header items are painted differently with a custom delegate.
gregsan
18th July 2008, 15:21
I already found a simple the solution.
If somebody else finds this widget box nice, here is how I do it:
1. I create a QDockWidget and put a QTreeWidget in it.
2. I set treeWidget.setRootIsDecorated(0)
3. Then I create a QTreeWidgetItem for each widget category and call
treeWidget.setItemWidget(item, 0, QPushButton("name", treeWidget))
4. I add widgets into each category by creating instances of QTreeWidgetItem.
Actually, instead of QPushButton I use MyPushButton, which is derived from QPushButton, in which I define mousePressEvent() using which I show or hide the widgets inside the category.
This is how the result looks like:
http://jimmy.fri.uni-lj.si/screen2.png
Quite similar to the Designer's gui, right.
Gregor
Powered by vBulletin® Version 4.2.5 Copyright © 2024 vBulletin Solutions Inc. All rights reserved.