user1257255
user1257255

Reputation: 1171

Qt C++ QToolBox: How to add checkbox/button to title

I would like to add checkbox or button into the toolbox's title and if it's checked then some action should be done (SINGAL - SLOT?). Is this possible or there is some other widget which provides that ability?

Upvotes: 2

Views: 2466

Answers (2)

Pavel Strakhov
Pavel Strakhov

Reputation: 40512

No, QToolBox doesn't support adding widgets to titles. A title can only contain a text.

However QToolBox is easy to implement. Just add QVBoxLayout, put titlebars and widgets in it. Then use titlebar's onclick events to call setVisible() on widgets to hide or show it. You may need to create separate form for titlebar, put your buttons inside it and reimplement QWidget::mousePressEvent to catch clicks. Then promote the main form's titlebar widgets to this class.

Upvotes: 4

WoJo
WoJo

Reputation: 370

create a QAction, make it checkable setCheckable(true) and connect to the toggled signal. it's not a checkbox but a button with the same behaviour. than add this action to the toolbox.

Upvotes: -1

Related Questions