dockwidgeteventfilter.cpp 611 Bytes
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
#include <QDockWidget>
#include <QEvent>
#include <QLabel>

#include "dockwidgeteventfilter.h"

DockWidgetEventFilter::DockWidgetEventFilter(QObject *parent) : QObject(parent) {}

bool DockWidgetEventFilter::eventFilter(QObject *object,QEvent *event)
{
    if (event->type() == QEvent::WindowTitleChange)
    {
        QDockWidget *dock = dynamic_cast<QDockWidget *>(object);
        if(dock) {
            QLabel *label = dynamic_cast<QLabel *>(dock->titleBarWidget());
            if(label)
                label->setText(dock->windowTitle());
        }
    }
    return QObject::eventFilter(object,event);
}