当前位置: 首页>>代码示例>>C++>>正文


C++ QListWidgetItem::setSelected方法代码示例

本文整理汇总了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);
    }
}
开发者ID:jonatho7,项目名称:opticks,代码行数:25,代码来源:FeatureClassDlg.cpp

示例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());
}
开发者ID:gottcode,项目名称:tetzle,代码行数:28,代码来源:new_game_tab.cpp

示例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);
    }
}
开发者ID:jonatho7,项目名称:opticks,代码行数:35,代码来源:FeatureClassDlg.cpp

示例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);
}
开发者ID:mrrooster,项目名称:Yasst,代码行数:35,代码来源:TrendingTopicsWidget.cpp

示例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 );
            }
        }
    }
开发者ID:KDE,项目名称:calligra-history,代码行数:27,代码来源:KPrPageLayoutDocker.cpp

示例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);
}
开发者ID:strahlex,项目名称:qt-apps-qmllive,代码行数:28,代码来源:optionsdialog.cpp

示例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();
}
开发者ID:Aconex,项目名称:pcp,代码行数:25,代码来源:settingsdialog.cpp

示例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();
}
开发者ID:petrpopov,项目名称:db_transactions,代码行数:31,代码来源:addcoursedialog.cpp

示例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));
}
开发者ID:liunianbanbo,项目名称:vnote,代码行数:33,代码来源:vnotebookselector.cpp

示例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*)));
}
开发者ID:anger123520,项目名称:qtwebkit-23_from_gitorious,代码行数:17,代码来源:WebPlugin.cpp

示例11: _invertSelection

	//-------------------------------------------------------------------------
	void HandleRootsDialog::_invertSelection()
	{
		for( int i = 0; i < _ui->rootFolders->count(); i++ )
		{
			QListWidgetItem* item = _ui->rootFolders->item( i );
			item->setSelected( !item->isSelected() );
		}
	}
开发者ID:danitrap,项目名称:depgraphv,代码行数:9,代码来源:handlerootsdialog.cpp

示例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);
    }
开发者ID:8c6794b6,项目名称:supercollider,代码行数:10,代码来源:QcListWidget.cpp

示例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);
}
开发者ID:3660628,项目名称:trunk,代码行数:10,代码来源:LASOpenDlg.cpp

示例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();

}
开发者ID:Kst-plot,项目名称:kst-subversion-archive,代码行数:12,代码来源:legendtab.cpp

示例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();
}
开发者ID:Kst-plot,项目名称:kst-subversion-archive,代码行数:12,代码来源:legendtab.cpp


注:本文中的QListWidgetItem::setSelected方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。