class UFoldoutGroupBox: public QGroupBox{ Q_OBJECTpublic: UFoldoutGroupBox(QWidget *parent = 0) : QGroupBox(parent) { setCheckable(true); setChecked(true); setExpanded(true); connect(this, SIGNAL(toggled(bool)), SLOT(setExpanded(bool))); }public slots: void setExpanded(bool expanded) { setFlat(!expanded); foreach(QWidget *child, findChildren <QWidget *> ()) child->setVisible(expanded); }};
QGroupBox { border-radius: 10px; }QGroupBox::title { subcontrol-origin: margin; subcontrol-position: top center; /* помещаем вверху по центру */ padding: 0 3px; }QGroupBox::indicator { width: 9px; height: 9px; } QGroupBox::indicator:unchecked { image: url(:/resource/close.png); } QGroupBox::indicator:checked { image: url(:/resource/open.png); }