Commit 3b1995f6 authored by Ingo Klöcker's avatar Ingo Klöcker
Browse files

Ensure that the first child widget is visible when it gets focus

For all other child widgets this is already ensured by
QScrollArea::focusNextPrevChild(), but this method is not called if
the focus policy of the scroll area is set to NoFocus (which we often do
because it confuses many users if the scroll area gets focus instead of
some input field or button).

Reacting on any focus change is a bit crude, but anything else is much
more complicated or does not work, e.g. setting the first widget as focus
proxy of the scroll area or overwriting focusInEvent() to call
focusNextPrevChild().

GnuPG-bug-id: 5969
parent 349db11a
......@@ -13,6 +13,7 @@
#include "scrollarea.h"
#include <QApplication>
#include <QResizeEvent>
#include <QScreen>
#include <QScrollBar>
......@@ -29,6 +30,11 @@ ScrollArea::ScrollArea(QWidget *parent)
setWidget(w);
setWidgetResizable(true);
w->installEventFilter(this);
connect(qApp, &QApplication::focusChanged, this, [this](QWidget *old, QWidget *now) {
Q_UNUSED(old);
ensureWidgetVisible(now);
});
}
ScrollArea::~ScrollArea()
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment