mirror of
https://github.com/xiaoyifang/goldendict-ng.git
synced 2024-11-23 20:14:05 +00:00
properly adjust status bar position when the main window resizes
This commit is contained in:
parent
354066c292
commit
74e7a41548
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -34,6 +34,7 @@ private:
|
|||
QLabel * textWidget;
|
||||
|
||||
QTimer * timer;
|
||||
bool eventFilter(QObject *obj, QEvent * event);
|
||||
void refresh();
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in a new issue