KCompletionBox
#include <KCompletionBox>
Signals | |
void | textActivated (const QString &text) |
void | userCancelled (const QString &) |
Public Slots | |
void | down () |
void | end () |
void | home () |
void | insertItems (const QStringList &items, int index=-1) |
void | pageDown () |
void | pageUp () |
virtual void | popup () |
void | setActivateOnSelect (bool doEmit) |
void | setCancelledText (const QString &text) |
void | setItems (const QStringList &items) |
void | setTabHandling (bool enable) |
void | setVisible (bool visible) override |
void | up () |
Protected Slots | |
virtual void | slotActivated (QListWidgetItem *) |
Protected Member Functions | |
QRect | calculateGeometry () const |
bool | eventFilter (QObject *, QEvent *) override |
virtual QPoint | globalPositionHint () const |
void | resizeAndReposition () |
Protected Member Functions inherited from QListWidget | |
virtual void | dropEvent (QDropEvent *event) override |
virtual bool | dropMimeData (int index, const QMimeData *data, Qt::DropAction action) |
virtual bool | event (QEvent *e) override |
virtual QMimeData * | mimeData (const QList< QListWidgetItem * > &items) const const |
virtual QStringList | mimeTypes () const const |
virtual Qt::DropActions | supportedDropActions () const const |
Protected Member Functions inherited from QListView | |
virtual void | currentChanged (const QModelIndex ¤t, const QModelIndex &previous) override |
virtual void | dataChanged (const QModelIndex &topLeft, const QModelIndex &bottomRight, const QList< int > &roles) override |
virtual void | dragLeaveEvent (QDragLeaveEvent *e) override |
virtual void | dragMoveEvent (QDragMoveEvent *e) override |
virtual int | horizontalOffset () const const override |
virtual void | initViewItemOption (QStyleOptionViewItem *option) const const override |
virtual bool | isIndexHidden (const QModelIndex &index) const const override |
virtual void | mouseMoveEvent (QMouseEvent *e) override |
virtual void | mouseReleaseEvent (QMouseEvent *e) override |
virtual QModelIndex | moveCursor (CursorAction cursorAction, Qt::KeyboardModifiers modifiers) override |
virtual void | paintEvent (QPaintEvent *e) override |
QRect | rectForIndex (const QModelIndex &index) const const |
virtual void | resizeEvent (QResizeEvent *e) override |
virtual void | rowsAboutToBeRemoved (const QModelIndex &parent, int start, int end) override |
virtual void | rowsInserted (const QModelIndex &parent, int start, int end) override |
virtual void | scrollContentsBy (int dx, int dy) override |
virtual QModelIndexList | selectedIndexes () const const override |
virtual void | selectionChanged (const QItemSelection &selected, const QItemSelection &deselected) override |
void | setPositionForIndex (const QPoint &position, const QModelIndex &index) |
virtual void | setSelection (const QRect &rect, QItemSelectionModel::SelectionFlags command) override |
virtual void | startDrag (Qt::DropActions supportedActions) override |
virtual void | timerEvent (QTimerEvent *e) override |
virtual void | updateGeometries () override |
virtual int | verticalOffset () const const override |
virtual QSize | viewportSizeHint () const const override |
virtual QRegion | visualRegionForSelection (const QItemSelection &selection) const const override |
virtual void | wheelEvent (QWheelEvent *e) override |
Protected Member Functions inherited from QAbstractItemView | |
virtual void | closeEditor (QWidget *editor, QAbstractItemDelegate::EndEditHint hint) |
virtual void | commitData (QWidget *editor) |
QPoint | dirtyRegionOffset () const const |
virtual void | dragEnterEvent (QDragEnterEvent *event) override |
DropIndicatorPosition | dropIndicatorPosition () const const |
virtual bool | edit (const QModelIndex &index, EditTrigger trigger, QEvent *event) |
virtual void | editorDestroyed (QObject *editor) |
void | executeDelayedItemsLayout () |
virtual void | focusInEvent (QFocusEvent *event) override |
virtual bool | focusNextPrevChild (bool next) override |
virtual void | focusOutEvent (QFocusEvent *event) override |
virtual void | inputMethodEvent (QInputMethodEvent *event) override |
virtual void | keyPressEvent (QKeyEvent *event) override |
virtual void | mouseDoubleClickEvent (QMouseEvent *event) override |
virtual void | mousePressEvent (QMouseEvent *event) override |
void | scheduleDelayedItemsLayout () |
void | scrollDirtyRegion (int dx, int dy) |
virtual QItemSelectionModel::SelectionFlags | selectionCommand (const QModelIndex &index, const QEvent *event) const const |
void | setDirtyRegion (const QRegion ®ion) |
void | setState (State state) |
State | state () const const |
virtual bool | viewportEvent (QEvent *event) override |
Protected Member Functions inherited from QAbstractScrollArea | |
virtual void | contextMenuEvent (QContextMenuEvent *e) override |
void | setViewportMargins (const QMargins &margins) |
void | setViewportMargins (int left, int top, int right, int bottom) |
QMargins | viewportMargins () const const |
Protected Member Functions inherited from QFrame | |
virtual void | changeEvent (QEvent *ev) override |
virtual void | initStyleOption (QStyleOptionFrame *option) const const |
Protected Member Functions inherited from QWidget | |
virtual void | actionEvent (QActionEvent *event) |
virtual void | closeEvent (QCloseEvent *event) |
void | create (WId window, bool initializeWindow, bool destroyOldWindow) |
void | destroy (bool destroyWindow, bool destroySubWindows) |
virtual void | enterEvent (QEnterEvent *event) |
bool | focusNextChild () |
bool | focusPreviousChild () |
virtual void | hideEvent (QHideEvent *event) |
virtual void | initPainter (QPainter *painter) const const override |
virtual void | keyReleaseEvent (QKeyEvent *event) |
virtual void | leaveEvent (QEvent *event) |
virtual int | metric (PaintDeviceMetric m) const const override |
virtual void | moveEvent (QMoveEvent *event) |
virtual bool | nativeEvent (const QByteArray &eventType, void *message, qintptr *result) |
virtual void | showEvent (QShowEvent *event) |
virtual void | tabletEvent (QTabletEvent *event) |
void | updateMicroFocus (Qt::InputMethodQuery query) |
Protected Member Functions inherited from QObject | |
virtual void | childEvent (QChildEvent *event) |
virtual void | connectNotify (const QMetaMethod &signal) |
virtual void | customEvent (QEvent *event) |
virtual void | disconnectNotify (const QMetaMethod &signal) |
bool | isSignalConnected (const QMetaMethod &signal) const const |
int | receivers (const char *signal) const const |
QObject * | sender () const const |
int | senderSignalIndex () const const |
Protected Member Functions inherited from QPaintDevice |
Additional Inherited Members | |
Public Types inherited from QListView | |
enum | Flow |
enum | LayoutMode |
enum | Movement |
enum | ResizeMode |
enum | ViewMode |
Public Types inherited from QAbstractItemView | |
enum | CursorAction |
enum | DragDropMode |
enum | DropIndicatorPosition |
enum | EditTrigger |
typedef | EditTriggers |
enum | ScrollHint |
enum | ScrollMode |
enum | SelectionBehavior |
enum | SelectionMode |
enum | State |
Public Types inherited from QAbstractScrollArea | |
enum | SizeAdjustPolicy |
Public Types inherited from QFrame | |
enum | Shadow |
enum | Shape |
enum | StyleMask |
Public Types inherited from QWidget | |
enum | RenderFlag |
typedef | RenderFlags |
Public Types inherited from QObject | |
typedef | QObjectList |
Public Types inherited from QPaintDevice | |
enum | PaintDeviceMetric |
Static Public Member Functions inherited from QWidget | |
QWidget * | createWindowContainer (QWindow *window, QWidget *parent, Qt::WindowFlags flags) |
QWidget * | find (WId id) |
QWidget * | keyboardGrabber () |
QWidget * | mouseGrabber () |
void | setTabOrder (QWidget *first, QWidget *second) |
void | setTabOrder (std::initializer_list< QWidget * > widgets) |
Static Public Member Functions inherited from QObject | |
QMetaObject::Connection | connect (const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type) |
QMetaObject::Connection | connect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &method, Qt::ConnectionType type) |
QMetaObject::Connection | connect (const QObject *sender, PointerToMemberFunction signal, const QObject *context, Functor functor, Qt::ConnectionType type) |
QMetaObject::Connection | connect (const QObject *sender, PointerToMemberFunction signal, const QObject *receiver, PointerToMemberFunction method, Qt::ConnectionType type) |
QMetaObject::Connection | connect (const QObject *sender, PointerToMemberFunction signal, Functor functor) |
bool | disconnect (const QMetaObject::Connection &connection) |
bool | disconnect (const QObject *sender, const char *signal, const QObject *receiver, const char *method) |
bool | disconnect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &method) |
bool | disconnect (const QObject *sender, PointerToMemberFunction signal, const QObject *receiver, PointerToMemberFunction method) |
QString | tr (const char *sourceText, const char *disambiguation, int n) |
Public Attributes inherited from QListView | |
Adjust | |
Batched | |
Fixed | |
Free | |
IconMode | |
LeftToRight | |
ListMode | |
SinglePass | |
Snap | |
Static | |
TopToBottom | |
Public Attributes inherited from QAbstractItemView | |
AboveItem | |
AllEditTriggers | |
AnimatingState | |
AnyKeyPressed | |
BelowItem | |
CollapsingState | |
ContiguousSelection | |
CurrentChanged | |
DoubleClicked | |
DragDrop | |
DraggingState | |
DragOnly | |
DragSelectingState | |
DropOnly | |
EditingState | |
EditKeyPressed | |
EnsureVisible | |
ExpandingState | |
ExtendedSelection | |
InternalMove | |
MoveDown | |
MoveEnd | |
MoveHome | |
MoveLeft | |
MoveNext | |
MovePageDown | |
MovePageUp | |
MovePrevious | |
MoveRight | |
MoveUp | |
MultiSelection | |
NoDragDrop | |
NoEditTriggers | |
NoSelection | |
NoState | |
OnItem | |
OnViewport | |
PositionAtBottom | |
PositionAtCenter | |
PositionAtTop | |
ScrollPerItem | |
ScrollPerPixel | |
SelectColumns | |
SelectedClicked | |
SelectItems | |
SelectRows | |
SingleSelection | |
Public Attributes inherited from QAbstractScrollArea | |
AdjustIgnored | |
AdjustToContents | |
AdjustToContentsOnFirstShow | |
Public Attributes inherited from QFrame | |
Box | |
HLine | |
NoFrame | |
Panel | |
Plain | |
Raised | |
Shadow_Mask | |
Shape_Mask | |
StyledPanel | |
Sunken | |
VLine | |
WinPanel | |
Public Attributes inherited from QWidget | |
DrawChildren | |
DrawWindowBackground | |
IgnoreMask | |
Public Attributes inherited from QPaintDevice | |
PdmDepth | |
PdmDevicePixelRatio | |
PdmDevicePixelRatioScaled | |
PdmDpiX | |
PdmDpiY | |
PdmHeight | |
PdmHeightMM | |
PdmNumColors | |
PdmPhysicalDpiX | |
PdmPhysicalDpiY | |
PdmWidth | |
PdmWidthMM | |
Detailed Description
A helper widget for "completion-widgets" (KLineEdit, KComboBox))
A little utility class for "completion-widgets", like KLineEdit or KComboBox. KCompletionBox is a listbox, displayed as a rectangle without any window decoration, usually directly under the lineedit or combobox. It is filled with all possible matches for a completion, so the user can select the one he wants.
It is used when KCompletion::CompletionMode == CompletionPopup or CompletionPopupAuto.
Definition at line 36 of file kcompletionbox.h.
Property Documentation
◆ activateOnSelect
|
readwrite |
Definition at line 41 of file kcompletionbox.h.
◆ cancelledText
|
readwrite |
Definition at line 40 of file kcompletionbox.h.
◆ isTabHandling
|
readwrite |
Definition at line 39 of file kcompletionbox.h.
Constructor & Destructor Documentation
◆ KCompletionBox()
|
explicit |
Constructs a KCompletionBox.
The parent widget is used to give the focus back when pressing the up-button on the very first item.
Definition at line 29 of file kcompletionbox.cpp.
◆ ~KCompletionBox()
|
override |
Destroys the box.
Definition at line 65 of file kcompletionbox.cpp.
Member Function Documentation
◆ activateOnSelect()
bool KCompletionBox::activateOnSelect | ( | ) | const |
- Returns
- true if selecting an item results in the emission of the selected() signal.
Definition at line 488 of file kcompletionbox.cpp.
◆ calculateGeometry()
|
protected |
This calculates the size of the dropdown and the relative position of the top left corner with respect to the parent widget.
This matches the geometry and position normally used by K/QComboBox when used with one.
Definition at line 347 of file kcompletionbox.cpp.
◆ cancelledText()
QString KCompletionBox::cancelledText | ( | ) | const |
- Returns
- the text set via setCancelledText() or QString().
Definition at line 432 of file kcompletionbox.cpp.
◆ down
|
slot |
Moves the selection one line down or select the first item if nothing is selected yet.
Definition at line 369 of file kcompletionbox.cpp.
◆ end
|
slot |
Moves the selection down to the last item.
Definition at line 412 of file kcompletionbox.cpp.
◆ eventFilter()
Reimplemented from QListWidget to get events from the viewport (to hide this widget on mouse-click, Escape-presses, etc.
Reimplemented from QAbstractItemView.
Definition at line 91 of file kcompletionbox.cpp.
◆ globalPositionHint()
|
protectedvirtual |
The preferred global coordinate at which the completion box's top left corner should be positioned.
Definition at line 308 of file kcompletionbox.cpp.
◆ home
|
slot |
Moves the selection up to the first item.
Definition at line 407 of file kcompletionbox.cpp.
◆ insertItems
|
slot |
Inserts items
into the box.
Does not clear the items before. index
determines at which position items
will be inserted. (defaults to appending them at the end)
Definition at line 437 of file kcompletionbox.cpp.
◆ isTabHandling()
bool KCompletionBox::isTabHandling | ( | ) | const |
- Returns
- true if this widget is handling Tab-key events to traverse the items in the dropdown list, otherwise false.
Default is true.
- See also
- setTabHandling
Definition at line 422 of file kcompletionbox.cpp.
◆ items()
QStringList KCompletionBox::items | ( | ) | const |
Returns a list of all items currently in the box.
Definition at line 70 of file kcompletionbox.cpp.
◆ pageDown
|
slot |
Moves the selection one page down.
Definition at line 397 of file kcompletionbox.cpp.
◆ pageUp
|
slot |
Moves the selection one page up.
Definition at line 402 of file kcompletionbox.cpp.
◆ popup
|
virtualslot |
Adjusts the size of the box to fit the width of the parent given in the constructor and pops it up at the most appropriate place, relative to the parent.
Depending on the screensize and the position of the parent, this may be a different place, however the default is to pop it up and the lower left corner of the parent.
Make sure to hide() the box when appropriate.
Definition at line 253 of file kcompletionbox.cpp.
◆ resizeAndReposition()
|
protected |
This properly resizes and repositions the listbox.
- Since
- 5.0
Definition at line 271 of file kcompletionbox.cpp.
◆ setActivateOnSelect
|
slot |
Set whether or not the selected signal should be emitted when an item is selected.
By default the selected() signal is emitted.
- Parameters
-
doEmit false if the signal should not be emitted.
Definition at line 483 of file kcompletionbox.cpp.
◆ setCancelledText
|
slot |
Sets the text to be emitted if the user chooses not to pick from the available matches.
If the cancelled text is not set through this function, the userCancelled signal will not be emitted.
- See also
- userCancelled( const QString& )
- Parameters
-
text the text to be emitted if the user cancels this box
Definition at line 427 of file kcompletionbox.cpp.
◆ setItems
|
slot |
Clears the box and inserts items
.
Definition at line 446 of file kcompletionbox.cpp.
◆ setTabHandling
|
slot |
Makes this widget (when visible) capture Tab-key events to traverse the items in the dropdown list (Tab goes down, Shift+Tab goes up).
On by default, but should be turned off when used in combination with KUrlCompletion. When off, KLineEdit handles Tab itself, making it select the current item from the completion box, which is particularly useful when using KUrlCompletion.
- See also
- isTabHandling
Definition at line 417 of file kcompletionbox.cpp.
◆ setVisible
|
overrideslot |
Reimplemented for internal reasons.
API is unaffected. Call it only if you really need it (i.e. the widget was hidden before) to have better performance.
Definition at line 316 of file kcompletionbox.cpp.
◆ sizeHint()
|
overridevirtual |
Reimplemented from QAbstractScrollArea.
Definition at line 364 of file kcompletionbox.cpp.
◆ slotActivated
|
protectedvirtualslot |
Called when an item is activated.
Emits KCompletionBox::textActivated(const QString &) with the item text.
- Note
- For releases <= 5.81, this slot emitted KCompletionBox::activated(const QString &) with the item text.
Definition at line 83 of file kcompletionbox.cpp.
◆ textActivated
|
signal |
Emitted when an item is selected, text
is the text of the selected item.
- Since
- 5.81
◆ up
|
slot |
Moves the selection one line up or select the first item if nothing is selected yet.
Definition at line 383 of file kcompletionbox.cpp.
◆ userCancelled
|
signal |
Emitted whenever the user chooses to ignore the available selections and closes this box.
The documentation for this class was generated from the following files:
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri Nov 29 2024 11:49:37 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006
KDE's Doxygen guidelines are available online.