I wanted to have a collapsible widget. I used this code: How to make an expandable/collapsable section widget in QT.
I wanted the title of the QToolButton
to be on the far left and the triangle icon to be on the right. I deleted the title, and moved the icon. Then I created a QPushButton
and made it look like a QLabel
and positioned it where I wanted the title to be. Now, I would like the title to be clickable - to have the same effect as clicking on the toggle icon would have. How do I connect these two signals?
Code for the QToolButton
:
QObject::connect(toggleButton, &QToolButton::clicked, [this](const bool checked)
{
toggleButton->setArrowType(checked ? Qt::ArrowType::DownArrow : Qt::ArrowType::UpArrow);
toggleAnimation->setDirection(checked ? QAbstractAnimation::Forward : QAbstractAnimation::Backward);
toggleAnimation->start();
});