PDA

View Full Version : Create "QGroupBoxCollapsible" - best approach?



irudkin
21st June 2007, 08:37
Hi All

I wish to create a widget which does everything QGroupBox does except is does not have 'Checkable' but has a button (+/-) in the the title area that when clicked on collapses/shrinks the widget to show just the title hiding any child widgets. What is the best approach? Looking at the QGroupBox code I need to derived my new widget direct from QWidget, not QGroupBox. However do I need to use QWidgetPrivate derived class too (private to me for a reason?)? What is the purpose of this class exactly? If a do use it what kind of functionality should it hold that would not be suitable to be containing in class QGroupBoxCollapsible : public QWidget?

Thanks
Cya Illya

jpn
25th June 2007, 16:24
I wish to create a widget which does everything QGroupBox does except is does not have 'Checkable' but has a button (+/-) in the the title area that when clicked on collapses/shrinks the widget to show just the title hiding any child widgets. What is the best approach?
1) subclass QGroupBox
2) show/hide children according to QGroupBox::toggled(bool)
3) use style sheets (::indicator subcontrol) to style the check indicator


Looking at the QGroupBox code I need to derived my new widget direct from QWidget, not QGroupBox. However do I need to use QWidgetPrivate derived class too (private to me for a reason?)? What is the purpose of this class exactly?
It's called pimpl (http://wiki.qtcentre.org/index.php?title=Private_Implementation).