本文整理汇总了C++中KLineEdit::setText方法的典型用法代码示例。如果您正苦于以下问题:C++ KLineEdit::setText方法的具体用法?C++ KLineEdit::setText怎么用?C++ KLineEdit::setText使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类KLineEdit
的用法示例。
在下文中一共展示了KLineEdit::setText方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: shouldEnablePushButtonWhenTestSizeSupperiorToTwo
void BlackListBalooEmailCompletionWidgetTest::shouldEnablePushButtonWhenTestSizeSupperiorToTwo()
{
KPIM::BlackListBalooEmailCompletionWidget widget;
KLineEdit *searchLineEdit = widget.findChild<KLineEdit *>(QStringLiteral("search_lineedit"));
QPushButton *seachButton = widget.findChild<QPushButton *>(QStringLiteral("search_button"));
QVERIFY(!seachButton->isEnabled());
searchLineEdit->setText(QStringLiteral("fo"));
QVERIFY(!seachButton->isEnabled());
searchLineEdit->setText(QStringLiteral("foo"));
QVERIFY(seachButton->isEnabled());
searchLineEdit->setText(QStringLiteral("o "));
QVERIFY(!seachButton->isEnabled());
searchLineEdit->setText(QStringLiteral(" o "));
QVERIFY(!seachButton->isEnabled());
}
示例2: setEditorData
void Delegate::setEditorData(QWidget *editor, const QModelIndex &index) const
{
QString value = index.model()->data(index, Qt::EditRole).toString();
KLineEdit *le = static_cast<KLineEdit*>(editor);
le->setText(value);
}
示例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: staticSetWidgetData
void CharDataInformation::staticSetWidgetData(quint8 value, QWidget* w)
{
KLineEdit* edit = dynamic_cast<KLineEdit*> (w);
if (edit)
{
QChar qchar(value, 0);
if (! qchar.isPrint())
qchar = QChar(QChar::ReplacementCharacter);
edit->setText( qchar );
}
}
示例5: setEditorData
void KonqBookmarkDelegate::setEditorData(QWidget *editor,
const QModelIndex &index) const
{
QString text = index.model()->data(index, Qt::EditRole).toString();
if(index.column() == KonqBookmarkModel::Url) {
LocationBar *LocationBarEditor = qobject_cast<LocationBar*>(editor);
LocationBarEditor->setText(text);
} else {
KLineEdit *kLineEditEditor = static_cast<KLineEdit*>(editor);
kLineEditEditor->setText(text);
}
}
示例6: setEditorData
void RuleDelegate::setEditorData(QWidget *editor, const QModelIndex &index) const
{
const QString rule = index.data(Qt::EditRole).toString();
if (rule.isEmpty())
{
return;
}
KLineEdit *ruleLineEdit = static_cast<KLineEdit*>(editor->layout()->itemAt(0)->widget());
ruleLineEdit->setText(rule.mid(rule.indexOf('+', 3) + 1));
KComboBox *matchComboBox = static_cast<KComboBox*>(editor->layout()->itemAt(1)->widget());
matchComboBox->setCurrentIndex(rule.mid(2, (rule.indexOf('+', 3) - 2)).toInt());
QCheckBox *requiredCheckBox = static_cast<QCheckBox*>(editor->layout()->itemAt(2)->widget());
requiredCheckBox->setChecked(rule.at(0) == '1');
}
示例7: executeRealFileOrDir
void KNewFileMenuPrivate::executeRealFileOrDir(const KNewFileMenuSingleton::Entry& entry)
{
// The template is not a desktop file
// Show the small dialog for getting the destination filename
QString text = entry.text;
text.remove("..."); // the ... is fine for the menu item but not for the default filename
text = text.trimmed(); // In some languages, there is a space in front of "...", see bug 268895
m_strategy.m_src = entry.templatePath;
KUrl defaultFile(m_popupFiles.first());
defaultFile.addPath(KIO::encodeFileName(text));
if (defaultFile.isLocalFile() && QFile::exists(defaultFile.toLocalFile()))
text = KIO::RenameDialog::suggestName(m_popupFiles.first(), text);
KDialog* fileDialog = new KDialog(m_parentWidget);
fileDialog->setAttribute(Qt::WA_DeleteOnClose);
fileDialog->setModal(q->isModal());
fileDialog->setButtons(KDialog::Ok | KDialog::Cancel);
QWidget* mainWidget = new QWidget(fileDialog);
QVBoxLayout *layout = new QVBoxLayout(mainWidget);
QLabel *label = new QLabel(entry.comment);
// We don't set the text of lineEdit in its constructor because the clear button would not be shown then.
// It seems that setClearButtonShown(true) must be called *before* the text is set to make it work.
// TODO: should probably be investigated and fixed in KLineEdit.
KLineEdit *lineEdit = new KLineEdit;
lineEdit->setClearButtonShown(true);
lineEdit->setText(text);
_k_slotTextChanged(text);
QObject::connect(lineEdit, SIGNAL(textChanged(const QString &)), q, SLOT(_k_slotTextChanged(const QString &)));
layout->addWidget(label);
layout->addWidget(lineEdit);
fileDialog->setMainWidget(mainWidget);
QObject::connect(fileDialog, SIGNAL(accepted()), q, SLOT(_k_slotRealFileOrDir()));
QObject::connect(fileDialog, SIGNAL(rejected()), q, SLOT(_k_slotAbortDialog()));
fileDialog->show();
lineEdit->selectAll();
lineEdit->setFocus();
}
示例8: setEditorData
void CharactersViewDelegate::setEditorData(QWidget* editor, const QModelIndex& index) const
{
switch (index.column())
{
case 0:
case 1:
{
KLineEdit* lineEdit = static_cast<KLineEdit*>(editor);
lineEdit->setText(index.data(Qt::EditRole).toString());
break;
}
case 2:
{
KComboBox* comboBox = static_cast<KComboBox*>(editor);
comboBox->setCurrentIndex(index.data(Qt::EditRole).toInt());
break;
}
default:
QStyledItemDelegate::setEditorData(editor, index);
}
}
示例9: NoteEditor
FileEditor::FileEditor(FileContent *fileContent, QWidget *parent)
: NoteEditor(fileContent), m_fileContent(fileContent)
{
KLineEdit *lineEdit = new KLineEdit(parent);
FocusWidgetFilter *filter = new FocusWidgetFilter(lineEdit);
QPalette palette;
palette.setColor(lineEdit->backgroundRole(), note()->backgroundColor());
palette.setColor(lineEdit->foregroundRole(), note()->textColor());
lineEdit->setPalette(palette);
lineEdit->setFont(note()->font());
lineEdit->setText(m_fileContent->fileName());
lineEdit->selectAll();
setInlineEditor(lineEdit);
connect(filter, SIGNAL(returnPressed()),
this, SIGNAL(askValidation()));
connect(filter, SIGNAL(escapePressed()),
this, SIGNAL(askValidation()));
connect(filter, SIGNAL(mouseEntered()),
this, SIGNAL(mouseEnteredEditorWidget()));
}
示例10: setEditorData
void KWQTableDelegate::setEditorData(QWidget * editor, const QModelIndex & index) const
{
KLineEdit *lineEdit = static_cast<KLineEdit*>(editor);
lineEdit->setText(index.data(Qt::DisplayRole).toString());
}
示例11: 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);
//.........这里部分代码省略.........
示例12: setText
void setText( const QString& text ) { edit->setText( text ); }