Skip to content

Blink kmessagewidget

Blinks the kmessagewidget if a request is done to animatedShow() when the widget is already shown.

toy code:

#include <KMessageWidget>
#include <QApplication>
#include <QBoxLayout>
#include <QPushButton>


int main(int argc, char *argv[]) {
        QApplication app(argc, argv);
        QWidget widget;
        auto *layout = new QBoxLayout(QBoxLayout::TopToBottom);
        widget.setLayout(layout);
        auto *msgWidget = new KMessageWidget();
        layout->addWidget(msgWidget);
        auto *btn = new QPushButton("btn");
        QObject::connect(btn, &QPushButton::clicked, [msgWidget]{
                msgWidget->setText("Abc" + msgWidget->text());
                msgWidget->animatedShow();
        });
        layout->addWidget(btn);
        widget.show();

        return app.exec();
}

Video:

simplescreenrecorder-2022-11-21_19.05.10

Merge request reports