2 #include <QApplication>
4 #include <QPropertyAnimation>
5 #include <QAbstractAnimation>
6 #include <QParallelAnimationGroup>
14 setStyleSheet(
"background:none");
15 setIconSize(QSize(8, 8));
16 setFont(QApplication::font());
17 connect(
this, &QToolButton::toggled, [=](
bool checked) {
18 setArrowType(checked ? Qt::ArrowType::DownArrow : Qt::ArrowType::RightArrow);
24 QToolButton::setText(
" " + text);
28 qInfo() <<
"Set content" << content;
29 assert(content !=
nullptr);
31 auto animation_ =
new QPropertyAnimation(content_,
"maximumHeight");
32 animation_->setStartValue(0);
33 animation_->setEasingCurve(QEasingCurve::InOutQuad);
34 animation_->setDuration(300);
35 animation_->setEndValue(content->geometry().height() + 10);
36 animator_.addAnimation(animation_);
38 content->setMaximumHeight(0);
43 animator_.setDirection(QAbstractAnimation::Backward);
48 animator_.setDirection(QAbstractAnimation::Forward);
54 QParallelAnimationGroup animator_;