本文整理汇总了C++中KLineEdit::text方法的典型用法代码示例。如果您正苦于以下问题:C++ KLineEdit::text方法的具体用法?C++ KLineEdit::text怎么用?C++ KLineEdit::text使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类KLineEdit
的用法示例。
在下文中一共展示了KLineEdit::text方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: shouldHaveDefaultValue
void BlackListBalooEmailCompletionWidgetTest::shouldHaveDefaultValue()
{
KPIM::BlackListBalooEmailCompletionWidget widget;
widget.show();
QTest::qWaitForWindowExposed(&widget);
QLabel *searchLabel = widget.findChild<QLabel *>(QStringLiteral("search_label"));
QVERIFY(searchLabel);
KLineEdit *searchLineEdit = widget.findChild<KLineEdit *>(QStringLiteral("search_lineedit"));
QVERIFY(searchLineEdit);
QVERIFY(searchLineEdit->isClearButtonShown());
QVERIFY(searchLineEdit->trapReturnKey());
QVERIFY(searchLineEdit->text().isEmpty());
QPushButton *seachButton = widget.findChild<QPushButton *>(QStringLiteral("search_button"));
QVERIFY(seachButton);
QVERIFY(!seachButton->isEnabled());
QLabel *moreResult = widget.findChild<QLabel *>(QStringLiteral("moreresultlabel"));
QVERIFY(moreResult);
QVERIFY(!moreResult->isVisible());
QLabel *mNumberOfEmailsFound = widget.findChild<QLabel *>(QStringLiteral("numberofemailsfound"));
QVERIFY(mNumberOfEmailsFound);
QVERIFY(mNumberOfEmailsFound->text().isEmpty());
QPushButton *showAllBlackListedEmails = widget.findChild<QPushButton *>(QStringLiteral("show_blacklisted_email_button"));
QVERIFY(showAllBlackListedEmails);
KPIM::BlackListBalooEmailList *emailList = widget.findChild<KPIM::BlackListBalooEmailList *>(QStringLiteral("email_list"));
QVERIFY(emailList);
QPushButton *selectButton = widget.findChild<QPushButton *>(QStringLiteral("select_email"));
QVERIFY(selectButton);
QVERIFY(!selectButton->isEnabled());
QPushButton *unselectButton = widget.findChild<QPushButton *>(QStringLiteral("unselect_email"));
QVERIFY(unselectButton);
QVERIFY(!unselectButton->isEnabled());
QLabel *excludeDomainLabel = widget.findChild<QLabel *>(QStringLiteral("domain_label"));
QVERIFY(excludeDomainLabel);
KLineEdit *excludeDomainLineEdit = widget.findChild<KLineEdit *>(QStringLiteral("domain_lineedit"));
QVERIFY(excludeDomainLineEdit);
QVERIFY(excludeDomainLineEdit->trapReturnKey());
QVERIFY(excludeDomainLineEdit->text().isEmpty());
QVERIFY(excludeDomainLineEdit->isClearButtonShown());
QVERIFY(!excludeDomainLineEdit->placeholderText().isEmpty());
KListWidgetSearchLine *searchInResult = widget.findChild<KListWidgetSearchLine *>(QStringLiteral("searchinresultlineedit"));
QVERIFY(searchInResult);
QVERIFY(!searchInResult->placeholderText().isEmpty());
QVERIFY(searchInResult->text().isEmpty());
QVERIFY(searchInResult->isClearButtonEnabled());
KPIM::BlackListBalooEmailWarning *blackListWarning = widget.findChild<KPIM::BlackListBalooEmailWarning *>(QStringLiteral("backlistwarning"));
QVERIFY(blackListWarning);
}
示例2: setModelData
void Delegate::setModelData(QWidget *editor, QAbstractItemModel *model,
const QModelIndex &index) const
{
KLineEdit *le = static_cast<KLineEdit*>(editor);
model->setData(index, le->text(), Qt::EditRole);
}
示例3: discardCompletion
void KrunnerHistoryComboBox::discardCompletion()
{
//FIXME: find a reliable way to see if the scene is empty; now defaults to
// never complete
bool emptyScene = false;
KLineEdit* edit = static_cast<KLineEdit*>(lineEdit());
bool suggestedCompletion = (edit->text() != edit->userText());
if (emptyScene && suggestedCompletion) {
// We hit TAB with an empty scene and a suggested completion:
// Complete but don't lose focus
edit->setText(edit->text());
} else if (suggestedCompletion) {
// We hit TAB with a non-empty scene and a suggested completion:
// Assume the user wants to switch input to the results scene and discard the completion
edit->setText(edit->userText());
}
}
示例4: if
void Security8021xAuthWidget::writeConfig()
{
Q_D(Security8021xAuthWidget);
for (int i = 0; i < d->layout->rowCount() - 1; i++)
{
KLineEdit *le = qobject_cast<KLineEdit*>(d->layout->itemAt(i, QFormLayout::FieldRole)->widget());
if (le) {
QString setting = le->property("setting").toString();
if (setting == QLatin1String("password")) {
d->setting->setPassword(le->text());
} else if (setting == QLatin1String("private-key-password")) {
d->setting->setPrivatekeypassword(le->text());
} else if (setting == QLatin1String("phase2-private-key-password")) {
d->setting->setPhase2privatekeypassword(le->text());
}
}
}
}
示例5: shouldHaveDefaultValue
void AkonadiSearchDebugDialogTest::shouldHaveDefaultValue()
{
Akonadi::Search::AkonadiSearchDebugDialog dlg;
Akonadi::Search::AkonadiSearchDebugWidget *debugWidget = dlg.findChild<Akonadi::Search::AkonadiSearchDebugWidget *>(QStringLiteral("akonadisearchdebugwidget"));
QVERIFY(debugWidget);
QPlainTextEdit *editorWidget = debugWidget->findChild<QPlainTextEdit *>(QStringLiteral("plaintexteditor"));
QVERIFY(editorWidget);
KLineEdit *lineEdit = debugWidget->findChild<KLineEdit *>(QStringLiteral("lineedit"));
QVERIFY(lineEdit);
QVERIFY(lineEdit->text().isEmpty());
}
示例6: on_urlInsert_button_clicked
void SxEditor::on_urlInsert_button_clicked()
{
KLineEdit *label = m_pUrlInsert->findChild<KLineEdit*>("label");
KLineEdit *link = m_pUrlInsert->findChild<KLineEdit*>("link");
QString labelTxt = label->text();
QString linkTxt = link->text();
if(labelTxt.isEmpty())
{
KMessageBox::information(m_pUrlInsert->rootWidget(), "超链接", "标签名不能为空", "确定");
return;
}
if(linkTxt.isEmpty())
{
KMessageBox::information(m_pUrlInsert->rootWidget(), "超链接", "链接的内容不能为空", "确定");
return;
}
m_pUrlInsert->setAccepted();
KTextCursor txtCursor = m_pTextEdit->textCursor();
txtCursor.insertText(labelTxt, Qt::blue, linkTxt, linkTxt, true);
}
示例7: shouldFillLineEditWhenWeWantToSearchItem
void AkonadiSearchDebugDialogTest::shouldFillLineEditWhenWeWantToSearchItem()
{
Akonadi::Search::AkonadiSearchDebugDialog dlg;
Akonadi::Search::AkonadiSearchDebugWidget *debugWidget = dlg.findChild<Akonadi::Search::AkonadiSearchDebugWidget *>(QStringLiteral("akonadisearchdebugwidget"));
QVERIFY(debugWidget);
KLineEdit *lineEdit = debugWidget->findChild<KLineEdit *>(QStringLiteral("lineedit"));
QVERIFY(lineEdit);
const int value = 42;
const QString akonadiItem = QString::number(value);
dlg.setAkonadiId(value);
QCOMPARE(lineEdit->text(), akonadiItem);
}
示例8: setModelData
void KonqBookmarkDelegate::setModelData(QWidget *editor, QAbstractItemModel *model,
const QModelIndex &index) const
{
QString text;
if(index.column() == KonqBookmarkModel::Url) {
LocationBar *LocationBarEditor = qobject_cast<LocationBar*>(editor);
text = LocationBarEditor->text();
} else {
KLineEdit *kLineEditEditor = static_cast<KLineEdit*>(editor);
text = kLineEditEditor->text();
}
model->setData(index, text, Qt::EditRole);
}
示例9: SettingWidget
Security8021xAuthWidget::Security8021xAuthWidget(Knm::Connection* connection, const QStringList &secrets, QWidget * parent)
: SettingWidget(*new Security8021xAuthWidgetPrivate, parent)
{
Q_D(Security8021xAuthWidget);
d->connection = connection;
d->setting = static_cast<Knm::Security8021xSetting *>(connection->setting(Knm::Setting::Security8021x));
d->layout = new QFormLayout(this);
this->setLayout(d->layout);
if (secrets.contains(QLatin1String("password"))) {
QLabel *label = new QLabel(this);
label->setText(i18n("Password:"));
KLineEdit *lineEdit = new KLineEdit(this);
lineEdit->setPasswordMode(true);
lineEdit->setProperty("setting", "password");
d->layout->addRow(label, lineEdit);
}
if (secrets.contains(QLatin1String("private-key-password"))) {
QLabel *label = new QLabel(this);
label->setText(i18n("Private Key Password:"));
KLineEdit *lineEdit = new KLineEdit(this);
lineEdit->setPasswordMode(true);
lineEdit->setProperty("setting", "private-key-password");
d->layout->addRow(label, lineEdit);
}
if (secrets.contains(QLatin1String("phase2-private-key-password"))) {
QLabel *label = new QLabel(this);
label->setText(i18n("Phase 2 Private Key Password:"));
KLineEdit *lineEdit = new KLineEdit(this);
lineEdit->setPasswordMode(true);
lineEdit->setProperty("setting", "phase2-private-key-password");
d->layout->addRow(label, lineEdit);
}
for (int i = 0; i < d->layout->rowCount(); i++)
{
KLineEdit *le = qobject_cast<KLineEdit*>(d->layout->itemAt(i, QFormLayout::FieldRole)->widget());
if (le && le->text().isEmpty()) {
le->setFocus(Qt::OtherFocusReason);
break;
}
}
QCheckBox *showPasswords = new QCheckBox(this);
showPasswords->setText(i18n("&Show password"));
d->layout->setWidget(d->layout->rowCount(), QFormLayout::FieldRole, showPasswords);
connect(showPasswords, SIGNAL(toggled(bool)), this, SLOT(showPasswordsToggled(bool)));
d->layout->addItem(new QSpacerItem(0, 0, QSizePolicy::Minimum, QSizePolicy::Expanding));
}
示例10: setModelData
void CharactersViewDelegate::setModelData(QWidget* editor, QAbstractItemModel* model, const QModelIndex& index) const
{
switch (index.column())
{
case 0:
case 1:
{
KLineEdit* lineEdit = static_cast<KLineEdit*>(editor);
model->setData(index, lineEdit->text());
break;
}
case 2:
{
KComboBox* comboBox = static_cast<KComboBox*>(editor);
model->setData(index, comboBox->currentIndex());
break;
}
default:
QStyledItemDelegate::setModelData(editor, model, index);
}
}
示例11: setModelData
void RuleDelegate::setModelData(QWidget *editor, QAbstractItemModel *model, const QModelIndex &index) const
{
KLineEdit *ruleLineEdit = static_cast<KLineEdit*>(editor->layout()->itemAt(0)->widget());
KComboBox *matchComboBox = static_cast<KComboBox*>(editor->layout()->itemAt(1)->widget());
QCheckBox *requiredCheckBox = static_cast<QCheckBox*>(editor->layout()->itemAt(2)->widget());
model->setData(index, ((matchComboBox->currentIndex() > 0)?(QString("%1+%2+%3").arg(requiredCheckBox->isChecked()?'1':'0').arg(matchComboBox->currentIndex()).arg(ruleLineEdit->text())):QString()), Qt::EditRole);
}
示例12: testGlobalSearch
void TestGlobalSearch::testGlobalSearch()
{
QString filename(QFile::decodeName(FILES_DATA_DIR "/TestGlobalSearch.kexi"));
kDebug() << filename;
NewArgs args(m_argv);
args.vals[args.count - 1] = qstrdup(QFile::encodeName(filename).constData());
KexiAboutData aboutData;
aboutData.setProgramName(ki18n(metaObject()->className()));
int result = KexiMainWindow::create(args.count, args.vals, aboutData);
QVERIFY(kapp);
QCOMPARE(result, 0);
KLineEdit *lineEdit = kexiTester().widget<KLineEdit*>("globalSearch.lineEdit");
QVERIFY(lineEdit);
QTreeView *treeView = kexiTester().widget<QTreeView*>("globalSearch.treeView");
QVERIFY(treeView);
lineEdit->setFocus();
// enter "cars", expect 4 completion items
QTest::keyClicks(lineEdit, "cars");
QVERIFY(treeView->isVisible());
int globalSearchCompletionListRows = treeView->model()->rowCount();
QCOMPARE(globalSearchCompletionListRows, 4);
// add "x", expect no completion items and hidden list
QTest::keyClicks(lineEdit, "x");
QVERIFY(!treeView->isVisible());
globalSearchCompletionListRows = treeView->model()->rowCount();
QCOMPARE(globalSearchCompletionListRows, 0);
// Escape should clear
QTest::keyClick(lineEdit, Qt::Key_Escape, Qt::NoModifier, GUI_DELAY);
QVERIFY(lineEdit->text().isEmpty());
QTest::keyClicks(lineEdit, "cars");
QVERIFY(treeView->isVisible());
treeView->setFocus();
QTest::keyPress(treeView, Qt::Key_Down, Qt::NoModifier, GUI_DELAY);
QTest::keyPress(treeView, Qt::Key_Down, Qt::NoModifier, GUI_DELAY);
QTest::keyPress(treeView, Qt::Key_Down, Qt::NoModifier, GUI_DELAY);
// 3rd row should be "cars" form
QModelIndexList selectedIndices = treeView->selectionModel()->selectedRows();
QCOMPARE(selectedIndices.count(), 1);
QCOMPARE(treeView->model()->data(selectedIndices.first(), Qt::DisplayRole).toString(), QLatin1String("cars"));
// check if proper entry of Project Navigator is selected
QTest::keyPress(treeView, Qt::Key_Enter, Qt::NoModifier, GUI_DELAY);
KexiProjectNavigator *projectNavigator = kexiTester().widget<KexiProjectNavigator*>("KexiProjectNavigator");
QVERIFY(projectNavigator);
KexiPart::Item* selectedPartItem = projectNavigator->selectedPartItem();
QVERIFY(selectedPartItem);
QCOMPARE(selectedPartItem->name(), QLatin1String("cars"));
QCOMPARE(selectedPartItem->partClass(), QLatin1String("org.kexi-project.form"));
if (m_goToEventLoop) {
result = kapp->exec();
QCOMPARE(result, 0);
}
}
示例13: setModelData
void KWQTableDelegate::setModelData(QWidget * editor, QAbstractItemModel * model, const QModelIndex & index) const
{
KLineEdit *lineEdit = static_cast<KLineEdit*>(editor);
model->setData(index, lineEdit->text());
}
示例14: KDialogBase
DialogCreateTag::DialogCreateTag(QWidget *parent, TagTreeNode* parentNode, const char *name)
: KDialogBase(parent, name, true, "", KDialogBase::Ok|KDialogBase::Cancel, KDialogBase::Ok, false )
, m_parentNode(parentNode) {
if (parentNode) {
this->setCaption(i18n("Create tag"));
} else {
this->setCaption(i18n("Create toplevel tag"));
}
QWidget* mainPanel = new QWidget(this, "mainPanel");
setMainWidget(mainPanel);
QVBoxLayout* mainPanelLayout = new QVBoxLayout(mainPanel, 0, 5, "mainPanelLayout");
mainPanelLayout->setAutoAdd(true);
// parent
if (parentNode) {
// newTagGroup
QGroupBox* parentTagGroup = new QGroupBox(i18n("Parent tag"), mainPanel, "parentTagGroup");
QGridLayout* parentTagGroupLayout = new QGridLayout(parentTagGroup, 4, 4, 20, 5, "parentTagGroupLayout");
parentTagGroupLayout->setRowSpacing(0, 10);
// type
QLabel* typeLabel = new QLabel(i18n("Type"), parentTagGroup, "typeLabel");
parentTagGroupLayout->addWidget(typeLabel, 1, 0);
KComboBox* typeComboBox = new KComboBox(false, parentTagGroup, "typeComboBox");
typeComboBox->insertItem(parentNode->tagNode()->typeName());
typeComboBox->setEnabled(false);
parentTagGroupLayout->addMultiCellWidget(typeComboBox, 1, 1, 1, 2);
// name
QLabel* nameLabel = new QLabel(i18n("Name"), parentTagGroup, "nameLabel");
parentTagGroupLayout->addWidget(nameLabel, 2, 0);
KLineEdit* nameLineEdit = new KLineEdit(parentTagGroup, "nameLineEdit");
nameLineEdit->setText(*parentNode->tagNode()->text());
nameLineEdit->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
nameLineEdit->setReadOnly(true);
parentTagGroupLayout->addMultiCellWidget(nameLineEdit, 2, 2, 1, 2);
// icon
QLabel* iconLabel = new QLabel(i18n("Icon"), parentTagGroup, "iconLabel");
parentTagGroupLayout->addWidget(iconLabel, 3, 0);
KLineEdit* iconLineEdit = new KLineEdit(parentTagGroup, "iconLineEdit");
iconLineEdit->setText(*parentNode->tagNode()->iconName());
iconLineEdit->setMinimumWidth(300);
iconLineEdit->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
iconLineEdit->setReadOnly(true);
parentTagGroupLayout->addWidget(iconLineEdit, 3, 1);
QPushButton* iconButton = new QPushButton(i18n("Icon"), parentTagGroup, "iconButton");
QIconSet iconSet = KGlobal::iconLoader()->loadIconSet(iconLineEdit->text(), KIcon::Small, Configuration::getInstance()->tagtreeIconSize(), true);
iconButton->setIconSet(iconSet);
iconButton->setText(QString::null);
iconButton->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
iconButton->setEnabled(true);
parentTagGroupLayout->addWidget(iconButton, 3, 2);
}
// newTagGroup
QGroupBox* newTagGroup = new QGroupBox(i18n("New tag"), mainPanel, "newTagGroup");
QGridLayout* newTagGroupLayout = new QGridLayout(newTagGroup, 4, 4, 20, 5, "newTagGroupLayout");
newTagGroupLayout->setRowSpacing(0, 10);
// type
QLabel* typeLabel = new QLabel(i18n("Type"), newTagGroup, "typeLabel");
newTagGroupLayout->addWidget(typeLabel, 1, 0);
m_typeComboBox = new KComboBox(false, newTagGroup, "typeComboBox");
m_typeComboBoxEntries = new QValueList<int>;
if (!parentNode) {
m_typeComboBox->insertItem(TagNode::tagNodeTypeName(TagNode::TYPE_TITLE));
m_typeComboBoxEntries->append(TagNode::tagNodeTypeId(TagNode::TYPE_TITLE));
}
m_typeComboBox->insertItem(TagNode::tagNodeTypeName(TagNode::TYPE_BOOLEAN));
m_typeComboBoxEntries->append(TagNode::tagNodeTypeId(TagNode::TYPE_BOOLEAN));
newTagGroupLayout->addMultiCellWidget(m_typeComboBox, 1, 1, 1, 2);
// name
QLabel* nameLabel = new QLabel(i18n("Name"), newTagGroup, "nameLabel");
newTagGroupLayout->addWidget(nameLabel, 2, 0);
m_nameLineEdit = new KLineEdit(newTagGroup, "nameLineEdit");
m_nameLineEdit->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
QObject::connect(m_nameLineEdit, SIGNAL(textChanged(const QString&)), this, SLOT(slotNameChanged(const QString&)));
newTagGroupLayout->addMultiCellWidget(m_nameLineEdit, 2, 2, 1, 2);
// icon
QLabel* iconLabel = new QLabel(i18n("Icon"), newTagGroup, "iconLabel");
newTagGroupLayout->addWidget(iconLabel, 3, 0);
m_iconLineEdit = new KLineEdit(newTagGroup, "iconLineEdit");
m_iconLineEdit->setMinimumWidth(300);
m_iconLineEdit->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
QObject::connect(m_iconLineEdit, SIGNAL(textChanged(const QString&)), this, SLOT(slotIconTextChanged(const QString&)));
newTagGroupLayout->addWidget(m_iconLineEdit, 3, 1);
//.........这里部分代码省略.........
示例15: if
bool
StdWidgetFactory::startEditing(const QCString &classname, QWidget *w, KFormDesigner::Container *container)
{
setWidget(w, container);
// m_container = container;
if(classname == "KLineEdit")
{
KLineEdit *lineedit = static_cast<KLineEdit*>(w);
createEditor(classname, lineedit->text(), lineedit, container, lineedit->geometry(), lineedit->alignment(), true);
return true;
}
else if(classname == "QLabel")
{
QLabel *label = static_cast<QLabel*>(w);
if(label->textFormat() == RichText)
{
//m_widget = w;
// setWidget(w, container);
editText();
}
else
createEditor(classname, label->text(), label, container, label->geometry(), label->alignment());
return true;
}
else if(classname == "KPushButton")
{
KPushButton *push = static_cast<KPushButton*>(w);
QRect r = w->style().subRect(QStyle::SR_PushButtonContents, w);
QRect editorRect = QRect(push->x() + r.x(), push->y() + r.y(), r.width(), r.height());
//r.setX(r.x() + 5);
//r.setY(r.y() + 5);
//r.setWidth(r.width()-10);
//r.setHeight(r.height() - 10);
createEditor(classname, push->text(), push, container, editorRect, Qt::AlignCenter, false, false, Qt::PaletteButton);
return true;
}
else if(classname == "QRadioButton")
{
QRadioButton *radio = static_cast<QRadioButton*>(w);
QRect r = w->style().subRect(QStyle::SR_RadioButtonContents, w);
QRect editorRect = QRect(radio->x() + r.x(), radio->y() + r.y(), r.width(), r.height());
createEditor(classname, radio->text(), radio, container, editorRect, Qt::AlignAuto);
return true;
}
else if(classname == "QCheckBox")
{
QCheckBox *check = static_cast<QCheckBox*>(w);
//QRect r(check->geometry());
//r.setX(r.x() + 20);
QRect r = w->style().subRect(QStyle::SR_CheckBoxContents, w);
QRect editorRect = QRect(check->x() + r.x(), check->y() + r.y(), r.width(), r.height());
createEditor(classname, check->text(), check, container, editorRect, Qt::AlignAuto);
return true;
}
else if((classname == "KComboBox") || (classname == "KListBox"))
{
QStringList list;
if(classname == "KListBox")
{
KListBox *listbox = (KListBox*)w;
for(uint i=0; i < listbox->count(); i++)
list.append(listbox->text(i));
}
else if(classname == "KComboBox")
{
KComboBox *combo = (KComboBox*)w;
for(int i=0; i < combo->count(); i++)
list.append(combo->text(i));
}
if(editList(w, list))
{
if(classname == "KListBox")
{
((KListBox*)w)->clear();
((KListBox*)w)->insertStringList(list);
}
else if(classname == "KComboBox")
{
((KComboBox*)w)->clear();
((KComboBox*)w)->insertStringList(list);
}
}
return true;
}
else if((classname == "KTextEdit") || (classname == "KDateTimeWidget") || (classname == "KTimeWidget") ||
(classname == "KDateWidget") || (classname == "KIntSpinBox")) {
disableFilter(w, container);
return true;
}
return false;
}