本文整理汇总了C++中KLineEdit::doCompletion方法的典型用法代码示例。如果您正苦于以下问题:C++ KLineEdit::doCompletion方法的具体用法?C++ KLineEdit::doCompletion怎么用?C++ KLineEdit::doCompletion使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类KLineEdit
的用法示例。
在下文中一共展示了KLineEdit::doCompletion方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: eventFilter
bool KCompletionBox::eventFilter( QObject *o, QEvent *e )
{
int type = e->type();
QWidget *wid = qobject_cast<QWidget*>(o);
if (o == this) {
return false;
}
if (wid && wid == d->m_parent &&
(type == QEvent::Move || type == QEvent::Resize)) {
hide();
return false;
}
if (wid && (wid->windowFlags() & Qt::Window) &&
type == QEvent::Move && wid == d->m_parent->window()) {
hide();
return false;
}
if (type == QEvent::MouseButtonPress && (wid && !isAncestorOf(wid))) {
if (!d->emitSelected && currentItem() && !qobject_cast<QScrollBar*>(o)) {
Q_ASSERT(currentItem());
emit currentTextChanged(currentItem()->text() );
}
hide();
e->accept();
return true;
}
if (wid && wid->isAncestorOf(d->m_parent) && isVisible()) {
if ( type == QEvent::KeyPress ) {
QKeyEvent *ev = static_cast<QKeyEvent *>( e );
switch ( ev->key() ) {
case Qt::Key_Backtab:
if ( d->tabHandling && (ev->modifiers() == Qt::NoButton ||
(ev->modifiers() & Qt::ShiftModifier)) ) {
up();
ev->accept();
return true;
}
break;
case Qt::Key_Tab:
if ( d->tabHandling && (ev->modifiers() == Qt::NoButton) ) {
down();
// #65877: Key_Tab should complete using the first
// (or selected) item, and then offer completions again
if (count() == 1) {
KLineEdit* parent = qobject_cast<KLineEdit*>(d->m_parent);
if (parent) {
parent->doCompletion(currentItem()->text());
} else {
hide();
}
}
ev->accept();
return true;
}
break;
case Qt::Key_Down:
down();
ev->accept();
return true;
case Qt::Key_Up:
// If there is no selected item and we've popped up above
// our parent, select the first item when they press up.
if ( !selectedItems().isEmpty() ||
mapToGlobal( QPoint( 0, 0 ) ).y() >
d->m_parent->mapToGlobal( QPoint( 0, 0 ) ).y() )
up();
else
down();
ev->accept();
return true;
case Qt::Key_PageUp:
pageUp();
ev->accept();
return true;
case Qt::Key_PageDown:
pageDown();
ev->accept();
return true;
case Qt::Key_Escape:
canceled();
ev->accept();
return true;
case Qt::Key_Enter:
case Qt::Key_Return:
if ( ev->modifiers() & Qt::ShiftModifier ) {
hide();
ev->accept(); // Consume the Enter event
return true;
}
break;
case Qt::Key_End:
if ( ev->modifiers() & Qt::ControlModifier )
{
end();
ev->accept();
//.........这里部分代码省略.........