本文整理汇总了C++中QListWidgetItem::setSelected方法的典型用法代码示例。如果您正苦于以下问题:C++ QListWidgetItem::setSelected方法的具体用法?C++ QListWidgetItem::setSelected怎么用?C++ QListWidgetItem::setSelected使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QListWidgetItem
的用法示例。
在下文中一共展示了QListWidgetItem::setSelected方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: removeFeatureClass
void FeatureClassDlg::removeFeatureClass()
{
QList<QListWidgetItem*> items = mpClassList->selectedItems();
for (int i = 0; i < items.count(); ++i)
{
QListWidgetItem* pItem = items[i];
if (pItem != NULL)
{
QString className = pItem->text();
// Remove the feature class from the member dynamic object
mpFeatureClasses->removeAttribute(className.toStdString());
// Remove the item from the list widget
delete pItem;
}
}
// The selected item was deleted, so just select the first item in the list
QListWidgetItem* pItem = mpClassList->item(0);
if (pItem != NULL)
{
pItem->setSelected(true);
}
}
示例2: filterImages
void NewGameTab::filterImages(const QStringList& filter)
{
// Filter items
QListWidgetItem* item;
int count = m_images->count();
for (int i = 0; i < count; ++i) {
item = m_images->item(i);
item->setHidden(!filter.contains(item->data(ImageRole).toString()));
}
// Select next item if current item was hidden
item = m_images->currentItem();
if (!item || item->isHidden()) {
int count = m_images->count();
for (int i = 0; i < count; ++i) {
item = m_images->item(i);
if (!item->isHidden()) {
item->setSelected(true);
m_images->setCurrentItem(item);
break;
}
}
}
// Disable tag button if no images are visible
item = m_images->currentItem();
m_tag_action->setEnabled(item && !item->isHidden());
}
示例3: loadFromSettings
void FeatureClassDlg::loadFromSettings()
{
mpClassList->clear();
Service<ConfigurationSettings> pSettings;
const DataVariant& classes = pSettings->getSetting(FEATURE_CLASS_SETTING);
const DynamicObject* pClasses = classes.getPointerToValue<DynamicObject>();
if (pClasses == NULL)
{
return;
}
mpFeatureClasses->merge(pClasses);
std::vector<std::string> classNames;
mpFeatureClasses->getAttributeNames(classNames);
for (std::vector<std::string>::const_iterator iter = classNames.begin(); iter != classNames.end(); ++iter)
{
QString className = QString::fromStdString(*iter);
if (className.isEmpty() == false)
{
QListWidgetItem* pItem = new QListWidgetItem(className, mpClassList);
pItem->setData(Qt::UserRole, QVariant(className));
pItem->setFlags(Qt::ItemIsEnabled | Qt::ItemIsSelectable | Qt::ItemIsEditable);
mpClassList->addItem(pItem);
}
}
QListWidgetItem* pItem = mpClassList->item(0);
if (pItem != NULL)
{
pItem->setSelected(true);
}
}
示例4: refreshList
void TrendingTopicsWidget::refreshList() {
QList<TrendingTopic> topics=currentTrends;
if (mode==TrendingTopicsFetcher::Daily)
topics=dailyTrends;
else if (mode==TrendingTopicsFetcher::Weekly)
topics=weeklyTrends;
int height=0;
ui.topics->clear();
for(int x=0;x<topics.size();x++) {
TrendingTopic topic = topics.at(x);
QString name = QString::number(x+1)+". ";
QListWidgetItem *item = new QListWidgetItem();
name+=topic.name;
item->setText(name);
if (topic.prevPos==-1)
item->setIcon(QIcon(":/trendstates/newentry.png"));
else if (topic.prevPos==x)
item->setIcon(QIcon(":/trendstates/stick.png"));
else if (topic.prevPos>x)
item->setIcon(QIcon(":/trendstates/up.png"));
else
item->setIcon(QIcon(":/trendstates/down.png"));
ui.topics->addItem(item);
if (currentName==topic.name) {
item->setSelected(true);
ui.topics->setCurrentItem(item);
}
height += ui.topics->visualItemRect(item).height();
}
ui.topics->setMinimumHeight(height);
ui.topics->setMaximumHeight(height);
}
示例5: slotActivePageChanged
void KPrPageLayoutDocker::slotActivePageChanged()
{
Q_ASSERT( m_view );
KPrPage * page = dynamic_cast<KPrPage*>( m_view->activePage() );
if ( page ) {
KPrPageLayout * layout = page->layout();
QListWidgetItem * item = m_layout2item.value( layout, 0 );
if ( item == 0 && layout != 0 && layout->type() == KPrPageLayout::Page ) {
item = addLayout( layout );
}
if ( item ) {
m_layoutsView->blockSignals( true );
item->setSelected( true );
m_layoutsView->blockSignals( false );
m_layoutsView->scrollToItem( item );
}
else {
QList<QListWidgetItem*> items = m_layoutsView->selectedItems();
foreach ( QListWidgetItem * i, items ) {
m_layoutsView->blockSignals( true );
i->setSelected( false );
m_layoutsView->blockSignals( false );
}
}
}
示例6: QDialog
OptionsDialog::OptionsDialog(QWidget *parent)
: QDialog(parent)
, ui(new Ui::OptionsDialog)
, m_httpProxyForm(new HttpProxyOptionPage(this))
, m_importPathsForm(new ImportPathOptionPage(this))
, m_hostsForm(new HostsOptionsPage(this))
{
ui->setupUi(this);
QListWidgetItem *item = new QListWidgetItem("HTTP Proxy");
int index = ui->optionsStack->addWidget(m_httpProxyForm);
item->setSelected(true);
item->setData(Qt::UserRole, index);
ui->optionsView->addItem(item);
item = new QListWidgetItem("Import Paths");
index = ui->optionsStack->addWidget(m_importPathsForm);
item->setData(Qt::UserRole, index);
ui->optionsView->addItem(item);
item = new QListWidgetItem("Hosts");
index = ui->optionsStack->addWidget(m_hostsForm);
item->setData(Qt::UserRole, index);
ui->optionsView->addItem(item);
connect(ui->optionsView, &QListWidget::currentItemChanged,
this, &OptionsDialog::optionSelected);
}
示例7: addHostButton_clicked
void SettingsDialog::addHostButton_clicked()
{
QIcon hostIcon = fileIconProvider->icon(QFileIconProvider::Computer);
const QString hostname = hostComboBox->currentText();
bool found = false;
for (int i = 0; i < savedHostsListWidget->count(); i++) {
QListWidgetItem *item = savedHostsListWidget->item(i);
if (item->text() != hostname) {
item->setSelected(false);
} else {
savedHostsListWidget->setCurrentItem(item);
found = true;
}
}
if (!found) {
QListWidgetItem *item = new QListWidgetItem(hostIcon, hostname);
savedHostsListWidget->addItem(item);
savedHostsListWidget->setCurrentItem(item);
globalSettings.savedHostsModified = true;
globalSettings.savedHosts << hostname;
}
removeHostButton->setEnabled(true);
writeSettings();
}
示例8: selectItem
void AddCourseDialog::selectItem()
{
QPushButton *button = qobject_cast<QPushButton *>( sender() );
if( !button )
return;
int row = listWidget->currentRow();
if( button->objectName() == "upButton" )
{
if( --row <= 0 )
row = 0;
}
else if( button->objectName() == "downButton" )
{
if( ++row >= listWidget->count() )
{
row = listWidget->count() - 1;
if( row <= 0 )
row = 0;
}
}
QListWidgetItem *item = listWidget->item(row);
if( !item )
return;
listWidget->setCurrentItem( item );
item->setSelected( true );
listWidget->setFocus();
}
示例9: popupListContextMenuRequested
void VNotebookSelector::popupListContextMenuRequested(QPoint p_pos)
{
QListWidgetItem *item = m_listWidget->itemAt(p_pos);
if (!item) {
return;
}
const VNotebook *nb = getNotebook(item);
if (!nb) {
return;
}
m_listWidget->clearSelection();
item->setSelected(true);
QMenu menu(this);
menu.setToolTipsVisible(true);
menu.addAction(m_deleteNotebookAct);
if (nb->isValid()) {
menu.addSeparator();
menu.addAction(m_recycleBinAct);
menu.addAction(m_emptyRecycleBinAct);
}
menu.addSeparator();
menu.addAction(m_openLocationAct);
if (nb->isValid()) {
menu.addAction(m_notebookInfoAct);
}
menu.exec(m_listWidget->mapToGlobal(p_pos));
}
示例10: populateList
void Popup::populateList()
{
QListWidgetItem* listItem;
for (int i = 0; i < m_data.itemCount(); ++i) {
if (m_data.itemType(i) == QWebSelectData::Option) {
listItem = new QListWidgetItem(m_data.itemText(i));
m_list->addItem(listItem);
listItem->setSelected(m_data.itemIsSelected(i));
} else if (m_data.itemType(i) == QWebSelectData::Group) {
listItem = new QListWidgetItem(m_data.itemText(i));
m_list->addItem(listItem);
listItem->setSelected(false);
listItem->setFlags(Qt::NoItemFlags);
}
}
connect(m_list, SIGNAL(itemClicked(QListWidgetItem*)), this, SLOT(onItemSelected(QListWidgetItem*)));
}
示例11: _invertSelection
//-------------------------------------------------------------------------
void HandleRootsDialog::_invertSelection()
{
for( int i = 0; i < _ui->rootFolders->count(); i++ )
{
QListWidgetItem* item = _ui->rootFolders->item( i );
item->setSelected( !item->isSelected() );
}
}
示例12: setSelection
void QcListWidget::setSelection( const QVariantList & list )
{
clearSelection();
Q_FOREACH( const QVariant & var, list )
{
int row = var.toInt();
QListWidgetItem *item = QListWidget::item(row);
if (item)
item->setSelected(true);
}
示例13: addEVLR
void LASOpenDlg::addEVLR(QString description)
{
QListWidgetItem* item = new QListWidgetItem(description);
evlrListWidget->addItem(item);
//auto select the entry
item->setSelected(true);
//auto enable the extraFieldGroupBox
extraFieldGroupBox->setEnabled(true);
extraFieldGroupBox->setChecked(true);
}
示例14: downButtonClicked
void LegendTab::downButtonClicked() {
for (int i=_displayedRelationList->count()-2; i>=0; --i) {
if (_displayedRelationList->item(i) && _displayedRelationList->item(i)->isSelected()) {
QListWidgetItem *item = _displayedRelationList->takeItem(i);
_displayedRelationList->insertItem(i+1, item);
item->setSelected(true);
}
}
updateButtons();
}
示例15: upButtonClicked
void LegendTab::upButtonClicked() {
//_displayedRelationList->setFocus();
for (int i=1; i<_displayedRelationList->count(); i++) {
if (_displayedRelationList->item(i) && _displayedRelationList->item(i)->isSelected()) {
QListWidgetItem *item = _displayedRelationList->takeItem(i);
_displayedRelationList->insertItem(i-1, item);
item->setSelected(true);
}
}
updateButtons();
}