6.0.0-rc4Source

QFocusFrame Class

The QFocusFrame class draws a frame around a widget, outside it. More…

Header#include <QFocusFrame>
CMaketarget_link_libraries(app PRIVATE Nt::Widgets)
ModuleNt Widgets C++ Classes
InheritsQWidget

List of all members, including inherited members

Public Functions

QFocusFrame(QWidget *parent = nullptr)
~QFocusFrame()
voidsetWidget(QWidget *widget)
QWidget *widget() const

Reimplemented Protected Functions

booleventFilter(QObject *watched, QEvent *event)
voidpaintEvent(QPaintEvent *event)

Detailed Description

A focus frame follows a widget: it sits around it, in the parent of the widget, and moves, resizes, shows and hides with it. It is meant for showing the focus around a widget that does not draw it itself:

auto *frame = new QFocusFrame(window);
frame->setWidget(canvas);

The frame lets the mouse through to the widgets under it.

See also QRubberBand.

Differences from Qt

The frame is drawn by Nt in the highlight color, not by the style, and it follows the widget it was given rather than the focus.

Member Function Documentation

[explicit] QFocusFrame::QFocusFrame(QWidget *parent = nullptr)

Constructs a focus frame with the given parent, which follows no widget.

[override] QFocusFrame::~QFocusFrame()

Destroys the focus frame.

[override, protected] bool QFocusFrame::eventFilter(QObject *watched, QEvent *event)

Reimplements QWidget::eventFilter().

Follows the moves, resizes, shows and hides of the widget.

[override, protected] void QFocusFrame::paintEvent(QPaintEvent *event)

Reimplements QWidget::paintEvent().

void QFocusFrame::setWidget(QWidget *widget)

Makes the frame follow widget, or no widget if it is nullptr or a window. The frame becomes a child of the parent of the widget.

See also widget().

QWidget * QFocusFrame::widget() const

Returns the widget that the frame follows, or nullptr.