From 74e7a41548f4aad9931946ea0223e305494ac27f Mon Sep 17 00:00:00 2001 From: Tvangeste Date: Sat, 9 Jul 2011 19:05:14 +0200 Subject: [PATCH] properly adjust status bar position when the main window resizes --- mainstatusbar.cc | 16 ++++++++++++++++ mainstatusbar.hh | 1 + 2 files changed, 17 insertions(+) diff --git a/mainstatusbar.cc b/mainstatusbar.cc index 4d5716ff..8b905b08 100644 --- a/mainstatusbar.cc +++ b/mainstatusbar.cc @@ -24,6 +24,7 @@ MainStatusBar::MainStatusBar(QWidget *parent) : QWidget(parent) picWidget->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed); timer = new QTimer(this); + timer->setSingleShot(true); // layout QHBoxLayout * layout = new QHBoxLayout; @@ -35,6 +36,8 @@ MainStatusBar::MainStatusBar(QWidget *parent) : QWidget(parent) layout->addWidget(textWidget); setLayout(layout); + parentWidget()->installEventFilter( this ); + connect( timer, SIGNAL( timeout() ), SLOT( clearMessage() ) ); } @@ -94,3 +97,16 @@ void MainStatusBar::mousePressEvent ( QMouseEvent * ) { clearMessage(); } + +bool MainStatusBar::eventFilter(QObject *, QEvent * e) +{ + switch ( e->type() ) { + case QEvent::Resize: + refresh(); + break; + default: + break; + }; + + return false; +} diff --git a/mainstatusbar.hh b/mainstatusbar.hh index febff5bf..6aa13291 100644 --- a/mainstatusbar.hh +++ b/mainstatusbar.hh @@ -34,6 +34,7 @@ private: QLabel * textWidget; QTimer * timer; + bool eventFilter(QObject *obj, QEvent * event); void refresh(); };