本文整理汇总了C++中QStringListModel类的典型用法代码示例。如果您正苦于以下问题:C++ QStringListModel类的具体用法?C++ QStringListModel怎么用?C++ QStringListModel使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了QStringListModel类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: QWidget
SearchForm::SearchForm(QWidget *parent) :
QWidget(parent),
ui(new Ui::SearchForm)
{
ui->setupUi(this);
table_name = "tabla";
c = new QCompleter(this);
QStringList list;
list<<"hola"<<"haber"<<"hay"<<"ha"<<"tambien"<<"tambor"<<"tata"
<<"hola"<<"haber"<<"hay"<<"ha"<<"tambien"<<"tambor"<<"tata";
list.sort();
QStringListModel * model = new QStringListModel();
model->setStringList(list);
c->setModelSorting(QCompleter::CaseInsensitivelySortedModel);
c->setCaseSensitivity(Qt::CaseInsensitive);
c->setWrapAround(false);
c->setModel(model);
ui->le_nombre->setCompleter(c);
table_model = new QSqlRelationalTableModel();
table_model->setTable("e_marca");
table_model->select();
ui->tableView->setModel(table_model);
}
示例2: fInfo
void AnimationList::addNewFile()
{
//// For some unknown reason passing "this" locks up the OSX qavimator window. Possibly a QT4 bug, needs investigation
#ifdef __APPLE__
QStringList files=QFileDialog::getOpenFileNames(NULL, "Choose an animation file", Settings::Instance()->lastPath(), ANIM_FILTER);
#else
QStringList files=QFileDialog::getOpenFileNames(this, "Choose an animation file", Settings::Instance()->lastPath(), ANIM_FILTER);
#endif
if(files.isEmpty())
return;
else
{
QFileInfo fInfo(files.last());
Settings::Instance()->setLastPath(fInfo.absoluteDir().absolutePath());
}
foreach(QString file, files)
{
if(file.isEmpty() || availableAnimations.contains(file))
continue;
else
{
if(file.endsWith(".avm", Qt::CaseInsensitive) || file.endsWith(".bvh", Qt::CaseInsensitive))
availableAnimations.append(files);
}
}
QStringListModel* model = dynamic_cast<QStringListModel*>(ui->availableAnimsListView->model());
model->setStringList(availableAnimations); //TODO: this is sooo lame. Find a dignified way
onSelectionChanged();
}
示例3: Q_ASSERT
void MRichTextEditDialogsManager::setTextStyleValues(const QString &fontfamily, int fontPointSize,
const QColor &fontColor)
{
Q_ASSERT(fontFamilyCombo);
int familyIndex = -1;
QStringListModel *fontFamilyModel = dynamic_cast<QStringListModel *>(fontFamilyCombo->itemModel());
if (fontFamilyModel) {
QStringList fontFamilies = fontFamilyModel->stringList();
familyIndex = fontFamilies.indexOf(fontfamily);
}
fontFamilyCombo->setCurrentIndex(familyIndex);
Q_ASSERT(fontSizeCombo);
QStringList fontSizeValues = generateFontSizeComboValues();
QStringListModel *fontSizeModel = dynamic_cast<QStringListModel *>(fontSizeCombo->itemModel());
if (fontSizeModel) {
fontSizeModel->setStringList(fontSizeValues);
}
//% "%L1 points"
QString fontSize(qtTrId("qtn_comm_font_size_value").arg(fontPointSize));
int sizeIndex = fontSizeValues.indexOf(fontSize);
fontSizeCombo->setCurrentIndex(sizeIndex);
Q_ASSERT(fontColorCombo);
fontColorCombo->setPickedColor(fontColor);
}
示例4: bouchotSettingsDialog
void QQBoardsSettings::addBouchot()
{
QQBouchotSettingsDialog bouchotSettingsDialog(this);
bouchotSettingsDialog.setGroups(m_listGroups);
bouchotSettingsDialog.setNames(m_listNames);
if(bouchotSettingsDialog.exec() == QDialog::Accepted)
{
QQBouchot::QQBouchotSettings bSettings = bouchotSettingsDialog.bouchotSettings();
QString bouchotName = bouchotSettingsDialog.bouchotName();
if(m_listNames.contains(bouchotName))
{
qWarning() << "Trying to insert a bouchot with an already existing name, that's forbidden";
}
else
{
m_listNames.append(bouchotName);
if(! m_listGroups.contains(bSettings.group()))
m_listGroups.append(bSettings.group());
QStringListModel *model = (QStringListModel *) ui->bouchotListView->model();
int numRow = model->rowCount();
model->insertRows(numRow,1);
model->setData(model->index(numRow), QVariant(bouchotName));
m_newBouchots.insert(bouchotName, bSettings);
m_oldBouchots.removeAll(bouchotName);
}
}
}
示例5: QStringListModel
void MainWindowMenuPlan::cleanListViewING() //Se borra el listview con los ingredientes mostrados en el apartado Ingredientes
{
QStringListModel *model = new QStringListModel();
model->removeRows(0, model->rowCount());
ui->listView_Ingredientes->setModel(model);
delete model;
}
示例6: folderSelected
void ConversationPage::folderSelected(const QModelIndex& index)
{
MPopupList *popupList = qobject_cast<MPopupList *>(sender());
if (!popupList)
return;
QStringListModel *model = (QStringListModel *) popupList->itemModel();
QStringList folders = model->stringList();
m_downloadFolder = QDir::homePath() + "/" + folders[index.row()];
QMailMessagePart::Location location = m_selectedAttachment.location();
location.setContainingMessageId(m_id);
if (m_selectedAttachment.hasBody())
{
// The content has already been downloaded to local device. No need to retrieve part from server.
emit downloadCompleted();
return;
}
m_retrievalAction = new QMailRetrievalAction(this);
connect(m_retrievalAction, SIGNAL(activityChanged(QMailServiceAction::Activity)),
this, SLOT(activityChanged(QMailServiceAction::Activity)));
m_retrievalAction->retrieveMessagePart(location);
}
示例7: GenericDelegate
void QuickEdit::VisibilityDelegateSetup()
{
GenericDelegate* visibilityDelegate = new GenericDelegate(ui->tvEditor, false);
visibilityDelegate->widgetCreator = [&](QWidget * parent)
{
QStringList visibilities = {"public" , "protected", "private", "package", "default"};
QComboBox* box = new QComboBox(parent);
QStringListModel* model = new QStringListModel;
model->setStringList(visibilities);
box->setModel(model);
box->setEditable(false);
return box;
};
visibilityDelegate->dataAccessor = [](QWidget * editor, const QModelIndex & index)
{
QString value = index.model()->data(index, Qt::EditRole).toString();
QComboBox *box = static_cast<QComboBox*>(editor);
box->setCurrentText(value);
};
visibilityDelegate->dataSetter = [](QWidget * editor,QAbstractItemModel* model, const QModelIndex &index)
{
QComboBox * box = static_cast<QComboBox*>(editor);
QString value = box->currentText();
model->setData(index, value, Qt::EditRole);
};
ui->tvEditor->setItemDelegateForColumn(columns.indexOf("visibility"), visibilityDelegate);
}
示例8: GenericDelegate
void QuickEdit::DirectionDelegateSetup()
{
GenericDelegate* delegate = new GenericDelegate(ui->tvEditor, false);
delegate->widgetCreator = [](QWidget* parent)
{
QStringList visibilities;
visibilities << "inout" << "in" << "out";
QComboBox* box = new QComboBox(parent);
QStringListModel* model = new QStringListModel;
model->setStringList(visibilities);
box->setModel(model);
box->setEditable(false);
return box;
};
delegate->dataAccessor = [](QWidget* editor, const QModelIndex& index)
{
QString value = index.model()->data(index, Qt::EditRole).toString();
QComboBox* box = static_cast<QComboBox*>(editor);
box->setCurrentText(value);
};
delegate->dataSetter = [](QWidget* editor, QAbstractItemModel* model, const QModelIndex& index)
{
QComboBox* box = static_cast<QComboBox*>(editor);
QString value = box->currentText();
model->setData(index, value, Qt::EditRole);
};
ui->tvEditor->setItemDelegateForColumn(columns.indexOf("direction"), delegate);
}
示例9: MPopupList
void ConversationPage::openAttachmentOpenDialog()
{
MPopupList *popuplist = new MPopupList();
QStringListModel *model = new QStringListModel(this);
QDir homeDir = QDir::home();
// Hack: hardcoded the list of applications for the 1.1 release
QStringList apps = QStringList()
//% "Music player"
<< qtTrId("xx_music_player")
//% "Photo viewer"
<< qtTrId("xx_photo_viewer")
//% "Video player"
<< qtTrId("xx_video player");
model->setStringList(apps);
popuplist->setItemModel(model);
//% "Select an application"
popuplist->setTitle(qtTrId("xx_select_an_application"));
popuplist->appear();
connect(popuplist, SIGNAL(clicked(const QModelIndex&)), SLOT(applicationSelected(const QModelIndex &)));
}
示例10: QLOG_TRACE_IN
//***********************************************************
//* Load the completer with the list of valid tag names
//***********************************************************
void TagEditorNewTag::loadCompleter() {
QLOG_TRACE_IN() << typeid(*this).name();
QList<int> tagList;
TagTable tagTable(global.db);
QStringList tagNames;
tagTable.getAll(tagList);
for (qint32 i=0; i<tagList.size(); i++) {
Tag t;
QString guid;
tagTable.getGuid(guid, tagList[i]);
tagTable.get(t, guid);
QString name = t.name;
qint32 tagAccount = tagTable.owningAccount(tagList[i]);
if (!currentTags.contains(name) && tagAccount == account)
tagNames << name;
}
qSort(tagNames.begin(), tagNames.end(), caseInsensitiveLessThan);
completer->setModelSorting(QCompleter::CaseInsensitivelySortedModel);
completer->setCaseSensitivity(Qt::CaseInsensitive);
setCompleter(completer);
QStringListModel *model;
model = (QStringListModel*)(completer->model());
if(model==NULL)
model = new QStringListModel();
model->setStringList(tagNames);
completer->setModel(model);
QLOG_TRACE_OUT() << typeid(*this).name();
}
示例11: showAutocompletion
void ScriptWidget::showAutocompletion(const QStringList &list, const QString &prefix)
{
// do not show single autocompletion which is identical to existing prefix
// or if it identical to prefix + '('.
if (list.count() == 1) {
if (list.at(0) == prefix ||
list.at(0) == (prefix + "(")) {
return;
}
}
// update list of completions
QStringListModel * model = static_cast<QStringListModel *>(_completer->model());
model->setStringList(list);
int currentLine = 0;
int currentIndex = 0;
_queryText->getCursorPosition(¤tLine, ¤tIndex);
int physicalLine = currentLine - _queryText->firstVisibleLine(); // "physical" line number in text editor (not logical)
int lineIndexLeft = _currentAutoCompletionInfo.lineIndexLeft();
QRect rect = _queryText->rect();
rect.setWidth(550);
rect.setHeight(editorHeight(physicalLine + 1));
rect.moveLeft(charWidth() * lineIndexLeft + autocompletionBoxLeftPosition());
_completer->complete(rect);
_completer->popup()->setCurrentIndex(_completer->completionModel()->index(0, 0));
_queryText->setIgnoreEnterKey(true);
_queryText->setIgnoreTabKey(true);
}
示例12: QWidget
QmitkLabelSetWidget::QmitkLabelSetWidget(QWidget *parent)
: QWidget(parent), m_DataStorage(nullptr), m_Completer(nullptr), m_ToolManager(nullptr)
{
m_Controls.setupUi(this);
m_ColorSequenceRainbow.GoToBegin();
m_ToolManager = mitk::ToolManagerProvider::GetInstance()->GetToolManager();
assert(m_ToolManager);
m_Controls.m_LabelSearchBox->setAlwaysShowClearIcon(true);
m_Controls.m_LabelSearchBox->setShowSearchIcon(true);
QStringList completionList;
completionList << "";
m_Completer = new QCompleter(completionList, this);
m_Completer->setCaseSensitivity(Qt::CaseInsensitive);
m_Controls.m_LabelSearchBox->setCompleter(m_Completer);
connect(m_Controls.m_LabelSearchBox, SIGNAL(returnPressed()), this, SLOT(OnSearchLabel()));
// connect( m_Controls.m_LabelSetTableWidget, SIGNAL(labelListModified(const QStringList&)), this, SLOT(
// OnLabelListModified(const QStringList&)) );
// connect( m_Controls.m_LabelSetTableWidget, SIGNAL(mergeLabel(int)), this, SLOT( OnMergeLabel(int)) );
QStringListModel *completeModel = static_cast<QStringListModel *>(m_Completer->model());
completeModel->setStringList(GetLabelStringList());
m_Controls.m_LabelSearchBox->setEnabled(false);
m_Controls.m_lblCaption->setText("");
InitializeTableWidget();
}
示例13: qDeleteAll
void AppearanceSettings::loadThemes()
{
QStringList themeNames;
QStringList installPaths = Qtopia::installPaths();
qDeleteAll(m_themes);
m_themes.clear();
for (int i=0; i<installPaths.size(); i++) {
QString path(installPaths[i] + "etc/themes/");
QDir dir;
if (!dir.exists(path)) {
qLog(UI) << "Theme style configuration path not found" << path.toLocal8Bit().data();
continue;
}
// read theme.conf files
dir.setPath(path);
dir.setNameFilters(QStringList("*.conf")); // No tr
for (uint j=0; j<dir.count(); j++) {
QString name = dir[j].mid(0, dir[j].length() - 5); // cut ".conf"
Theme *theme = Theme::create(path + dir[j], name);
if (theme) {
m_themes << theme;
themeNames << theme->name();
}
}
}
themeNames << m_moreThemes;
QStringListModel *model;
model = qobject_cast<QStringListModel *>(m_themeCombo->model());
model->setStringList(themeNames);
}
示例14: wizard
void OwncloudWizardResultPage::initializePage()
{
/*
const QString localFolder = wizard()->property("localFolder").toString();
QString text;
if( _remoteFolder == QLatin1String("/") || _remoteFolder.isEmpty() ) {
text = tr("Your entire account is synced to the local folder <i>%1</i>")
.arg(QDir::toNativeSeparators(localFolder));
} else {
text = tr("%1 folder <i>%1</i> is synced to local folder <i>%2</i>")
.arg(Theme::instance()->appNameGUI())
.arg(_remoteFolder).arg(QDir::toNativeSeparators(localFolder));
}
_ui.localFolderLabel->setText( text );
*/
QStringList folders = wizard()->property("localFolders").value<QStringList>();
foreach (const QString &str, folders) {
qDebug()<<"folder selected : " << str;
}
QListView *list=_ui.listView;
QStringListModel *model = new QStringListModel(this);
model->setStringList(folders);
//list->setViewMode(QListView::IconMode);
list->setModel(model);
}
示例15: parseModelFUN
void PluginGame5GenerateSituationDialog::onPluginAction()
{
QStringList funList = parseModelFUN();
QStringListModel* stringModel = (QStringListModel*)lineEditCustom->completer()->model();
stringModel->setStringList(funList);
exec();
}