本文整理汇总了C++中KLineEdit::setClearButtonEnabled方法的典型用法代码示例。如果您正苦于以下问题:C++ KLineEdit::setClearButtonEnabled方法的具体用法?C++ KLineEdit::setClearButtonEnabled怎么用?C++ KLineEdit::setClearButtonEnabled使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类KLineEdit
的用法示例。
在下文中一共展示了KLineEdit::setClearButtonEnabled方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: OnlineSearchQueryFormAbstract
OnlineSearchQueryFormGeneral::OnlineSearchQueryFormGeneral(QWidget *parent)
: OnlineSearchQueryFormAbstract(parent),
configGroupName(QStringLiteral("Search Engine General"))
{
QFormLayout *layout = new QFormLayout(this);
layout->setMargin(0);
QLabel *label = new QLabel(i18n("Free text:"), this);
KLineEdit *lineEdit = new KLineEdit(this);
layout->addRow(label, lineEdit);
lineEdit->setClearButtonEnabled(true);
lineEdit->setFocus(Qt::TabFocusReason);
queryFields.insert(OnlineSearchAbstract::queryKeyFreeText, lineEdit);
label->setBuddy(lineEdit);
connect(lineEdit, &KLineEdit::returnPressed, this, &OnlineSearchQueryFormGeneral::returnPressed);
label = new QLabel(i18n("Title:"), this);
lineEdit = new KLineEdit(this);
layout->addRow(label, lineEdit);
lineEdit->setClearButtonEnabled(true);
queryFields.insert(OnlineSearchAbstract::queryKeyTitle, lineEdit);
label->setBuddy(lineEdit);
connect(lineEdit, &KLineEdit::returnPressed, this, &OnlineSearchQueryFormGeneral::returnPressed);
label = new QLabel(i18n("Author:"), this);
lineEdit = new KLineEdit(this);
layout->addRow(label, lineEdit);
lineEdit->setClearButtonEnabled(true);
queryFields.insert(OnlineSearchAbstract::queryKeyAuthor, lineEdit);
label->setBuddy(lineEdit);
connect(lineEdit, &KLineEdit::returnPressed, this, &OnlineSearchQueryFormGeneral::returnPressed);
label = new QLabel(i18n("Year:"), this);
lineEdit = new KLineEdit(this);
layout->addRow(label, lineEdit);
lineEdit->setClearButtonEnabled(true);
queryFields.insert(OnlineSearchAbstract::queryKeyYear, lineEdit);
label->setBuddy(lineEdit);
connect(lineEdit, &KLineEdit::returnPressed, this, &OnlineSearchQueryFormGeneral::returnPressed);
label = new QLabel(i18n("Number of Results:"), this);
numResultsField = new QSpinBox(this);
layout->addRow(label, numResultsField);
numResultsField->setMinimum(3);
numResultsField->setMaximum(100);
numResultsField->setValue(20);
label->setBuddy(numResultsField);
loadState();
}
示例2: setupUI
void setupUI() {
p->setObjectName(QStringLiteral("FieldLineEdit"));
hLayout = new QHBoxLayout(p);
hLayout->setMargin(0);
hLayout->setSpacing(2);
m_pushButtonType = new QPushButton(p);
appendWidget(m_pushButtonType);
hLayout->setStretchFactor(m_pushButtonType, 0);
m_pushButtonType->setObjectName(QStringLiteral("FieldLineEditButton"));
if (isMultiLine) {
m_multiLineEditText = new KTextEdit(p);
appendWidget(m_multiLineEditText);
connect(m_multiLineEditText, &KTextEdit::textChanged, p, &MenuLineEdit::slotTextChanged);
m_multiLineEditText->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Preferred);
p->setFocusProxy(m_multiLineEditText);
m_multiLineEditText->setAcceptRichText(false);
} else {
m_singleLineEditText = new KLineEdit(p);
appendWidget(m_singleLineEditText);
hLayout->setStretchFactor(m_singleLineEditText, 100);
m_singleLineEditText->setClearButtonEnabled(true);
m_singleLineEditText->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Preferred);
m_singleLineEditText->setCompletionMode(KCompletion::CompletionPopup);
m_singleLineEditText->completionObject()->setIgnoreCase(true);
p->setFocusProxy(m_singleLineEditText);
connect(m_singleLineEditText, &KLineEdit::textEdited, p, &MenuLineEdit::textChanged);
}
p->setFocusPolicy(Qt::StrongFocus); // FIXME improve focus handling
p->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Preferred);
}