本文整理汇总了C++中QCompleter::popup方法的典型用法代码示例。如果您正苦于以下问题:C++ QCompleter::popup方法的具体用法?C++ QCompleter::popup怎么用?C++ QCompleter::popup使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QCompleter
的用法示例。
在下文中一共展示了QCompleter::popup方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: showAutocompletionMenu
void BAbstractFileType::showAutocompletionMenu(BAbstractCodeEditorDocument *doc, QTextCursor cursor, const QPoint &)
{
if (cursor.isNull())
return;
QCompleter *completer = doc->findChild<QCompleter *>("beqt/completer");
cursor.select(QTextCursor::WordUnderCursor);
if (!cursor.hasSelection()) {
if (completer)
completer->popup()->hide();
return;
}
QList<AutocompletionItem> list = createAutocompletionItemList(doc, cursor);
if (list.isEmpty()) {
if (completer)
completer->popup()->hide();
return;
}
QStandardItemModel *model = doc->findChild<QStandardItemModel *>("beqt/completion_model");
if (!model) {
model = new QStandardItemModel(doc);
model->setObjectName("beqt/completion_model");
model->setColumnCount(1);
}
model->clear();
foreach (const AutocompletionItem &item, list) {
QStandardItem *si = new QStandardItem(item.actionIcon, item.actionText);
si->setData(item.actionToolTip, Qt::ToolTipRole);
si->setData(item.text, Qt::UserRole);
model->appendRow(si);
}
示例2: updateArgumentCompleter
void MainWindow::updateArgumentCompleter(QStringList *list, bool google)
{
editingCompleter++;
QCompleter *completer = ui->txtArgument->completer();
if (completer == NULL) {
completer = new QCompleter(*list, ui->txtArgument);
ui->txtArgument->setCompleter(completer);
} else {
QStringListModel *model = new QStringListModel(*list, completer);
completer->setModel(model);
}
completer->setCaseSensitivity(Qt::CaseInsensitive);
completer->setCompletionMode(QCompleter::PopupCompletion);
completer->popup()->installEventFilter(this);
completer->popup()->setItemDelegate(new GoogleResultDelegate());
if (google) {
completer->setMaxVisibleItems(21);
} else {
completer->setMaxVisibleItems(7);
}
completer->setCompletionPrefix(ui->txtArgument->text());
if (!list->isEmpty()) {
completer->complete();
}
editingCompleter--;
}
示例3: setZipLineEdit
/** Define the QLineEdit to use as zip code editor */
void ZipCountryCompleters::setZipLineEdit(QLineEdit *zip)
{
m_Zip = zip;
// Completer
QCompleter *completer = new QCompleter(this);
completer->setModel(m_Model);
completer->setCompletionColumn(ZipCountryModel::ZipCity);
completer->setCaseSensitivity(Qt::CaseInsensitive);
completer->setCompletionMode(QCompleter::UnfilteredPopupCompletion);
completer->popup()->setAlternatingRowColors(true);
zip->setCompleter(completer);
connect(m_Zip, SIGNAL(textChanged(QString)), this, SLOT(zipTextChanged()));
connect(completer, SIGNAL(activated(QModelIndex)), this, SLOT(indexActivated(QModelIndex)));
// button
m_ZipButton = new QToolButton(m_Zip);
m_ZipButton->setToolTip("Zip button");
m_ZipButton->setToolButtonStyle(Qt::ToolButtonIconOnly);
m_ZipButton->setIconSize(QSize(16,16));
m_ZipButton->setIcon(QIcon(QDir::cleanPath(qApp->applicationDirPath() + "/../../../../../global_resources/pixmap/16x16/ok.png")));
m_ZipButton->setMinimumSize(20,20);
m_ZipButton->setMaximumSize(20,20);
m_ZipButton->setStyleSheet("QToolButton { border: none; padding: 0px; }");
m_ZipButton->show();
int frameWidth = m_Zip->style()->pixelMetric(QStyle::PM_DefaultFrameWidth);
QSize msz = m_Zip->minimumSizeHint();
m_Zip->setMinimumSize(qMax(msz.width(), m_ZipButton->maximumHeight() + frameWidth * 2 + 2),
qMax(msz.height(), m_ZipButton->maximumHeight() + frameWidth * 2 + 2));
m_Zip->setStyleSheet(QString("padding-left: %1px;").arg(m_ZipButton->sizeHint().width() + frameWidth));
m_Zip->installEventFilter(this);
}
示例4: KLineEdit
KBicEdit::KBicEdit(QWidget* parent)
: KLineEdit(parent)
{
QCompleter* completer = new QCompleter(this);
bicModel* model = new bicModel(this);
completer->setModel(model);
m_popupDelegate = new bicItemDelegate(this);
completer->popup()->setItemDelegate(m_popupDelegate);
setCompleter(completer);
bicValidator *const validator = new bicValidator(this);
setValidator(validator);
}
示例5: readScripts
void ProjectReader::readScripts(QString &path, QString &name, bool open) {
Q_ASSERT(xml.isStartElement() && xml.name() == QLatin1String("Script"));
QString n;
Highlighter *h;
QCompleter *c;
CodeEditor *editor = new CodeEditor(name, 0, h);
if (open) {
editor = 0;
mMw->addCodeEditor(path + "/" + name);
} else {
editor->setUndoRedoEnabled(true);
editor->setTabStopWidth(29);
#ifdef Q_WS_MAC
int size = 12;
QFont font("Monaco", size);
#endif
#ifdef Q_OS_WIN
int size = 10;
QFont font("Consolas", size);
#endif
#ifdef Q_OS_LINUX
int size = 10;
QFont font("Inconsolata-g", size);
#endif
editor->setFont(font);
h = new Highlighter(editor->document());
c = new QCompleter();
c->setModel(mDocumentManager->modelFromFile(":/wordlist.txt"));
c->setModelSorting(QCompleter::CaseInsensitivelySortedModel);
c->setCaseSensitivity(Qt::CaseInsensitive);
c->setWrapAround(false);
c->popup()->setStyleSheet("color: #848484; background-color: #2E2E2E; selection-background-color: #424242;");
editor->setCompleter(c);
n = path + "/" + name;
//qDebug() << "look a script" << n;
editor->openFile(path + "/" + name);
mMw->addCodeEditor(editor, open);
}
xml.skipCurrentElement();
}
示例6: setZipLineEdit
/** Define the QLineEdit to use as zip code editor */
void ZipCountryCompleters::setZipLineEdit(Utils::QButtonLineEdit *zip)
{
m_zipEdit = zip;
// Completer
QCompleter *completer = new QCompleter(this);
completer->setModel(m_ZipModel);
completer->setCompletionColumn(ZipCountryModel::ZipCity);
completer->setCaseSensitivity(Qt::CaseInsensitive);
completer->setCompletionMode(QCompleter::PopupCompletion);
completer->popup()->setAlternatingRowColors(true);
m_zipEdit->setCompleter(completer);
connect(m_zipEdit, SIGNAL(textChanged(QString)), this, SLOT(zipTextChanged()));
connect(completer, SIGNAL(activated(QModelIndex)), this, SLOT(onCompleterIndexActivated(QModelIndex)));
// button
m_ZipButton = new QToolButton(m_zipEdit);
m_ZipButton->setIcon(theme()->icon(Core::Constants::ICONHELP));
m_zipEdit->setRightButton(m_ZipButton);
}
示例7: autocompletionMenuVisible
bool BAbstractFileType::autocompletionMenuVisible(BAbstractCodeEditorDocument *doc) const
{
QCompleter *completer = doc ? doc->findChild<QCompleter *>("beqt/completer") : 0;
return completer && completer->popup()->isVisible();
}