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


C++ QListWidget::setCurrentItem方法代码示例

本文整理汇总了C++中QListWidget::setCurrentItem方法的典型用法代码示例。如果您正苦于以下问题:C++ QListWidget::setCurrentItem方法的具体用法?C++ QListWidget::setCurrentItem怎么用?C++ QListWidget::setCurrentItem使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在QListWidget的用法示例。


在下文中一共展示了QListWidget::setCurrentItem方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: setEditorData

void OperationsDelegate::setEditorData(QWidget *editor,
                                       const QModelIndex &index) const
      {
      const QVariant value = index.data(Qt::EditRole);
      if (value.type() == QVariant::StringList) {
            QListWidget *lw = qobject_cast<QListWidget *>(editor);
            const auto items = lw->findItems(index.data(Qt::DisplayRole).toString(), Qt::MatchExactly);
            if (!items.empty())
                  lw->setCurrentItem(items.first());
            else
                  lw->setCurrentItem(lw->item(0));

            const int extraWidth = 25;
            const int extraHeight = 6;
            lw->setMinimumWidth(lw->sizeHintForColumn(0) + extraWidth);
                        // to prevent possible hiding bottom part of the list
            const int h = lw->count() * (lw->visualItemRect(lw->currentItem()).height() + extraHeight);
            const int y = (lw->parentWidget() && (lw->parentWidget()->rect().bottom() < lw->y() + h))
                        ? lw->parentWidget()->rect().bottom() - h - extraHeight : lw->y();
            lw->setGeometry(lw->x(), y, lw->width(), h);
                        // now lw can be partially hidden behind the tree view
                        // if tree view has small rect, so set parent of lw
                        // to app window and map coordinates accordingly to leave lw in place
            const auto globalCoord = lw->parentWidget()->mapToGlobal(lw->geometry().topLeft());
            lw->setParent(appWindow);
            const auto newLocalCoord = appWindow->mapFromGlobal(globalCoord);
            lw->setGeometry(newLocalCoord.x(), newLocalCoord.y(), lw->width(), h);
            }
      else        // single value
            QStyledItemDelegate::setEditorData(editor, index);
      }
开发者ID:CFrei,项目名称:MuseScore,代码行数:31,代码来源:importmidi_opdelegate.cpp

示例2: focusAssistant

void MainWindow::focusAssistant()
{
    QListWidget* widget = qobject_cast<QListWidget*>(m_assistantToolBox->currentWidget());
    if (widget) {
        widget->setFocus();
        if (widget->selectedItems().count() == 0) {
            widget->setCurrentItem(widget->itemAt(0, 0));
        }
    }
}
开发者ID:JoyIfBam5,项目名称:plantumlqeditor,代码行数:10,代码来源:mainwindow.cpp

示例3: buttonAddClicked

void KActionSelectorPrivate::buttonAddClicked()
{
  // move all selected items from available to selected listbox
  QList<QListWidgetItem *> list = availableListWidget->selectedItems();
  foreach (QListWidgetItem* item, list) {
    availableListWidget->takeItem( availableListWidget->row( item ) );
    selectedListWidget->insertItem( insertionIndex( selectedListWidget, selectedInsertionPolicy ), item );
    selectedListWidget->setCurrentItem( item );
    emit q->added( item );
  }
开发者ID:vasi,项目名称:kdelibs,代码行数:10,代码来源:kactionselector.cpp

示例4: ProcessChanged

void MainWindow::ProcessChanged(Process* _process)
{
  QListWidgetItem* item = this->GetProcessItem(_process);
  QListWidget*     list = this->ui.procListWidget;
  if(item != NULL);
  {
    list->setCurrentItem(item);
    this->DisplayProcess();
  }
}
开发者ID:dpsm,项目名称:pwatchdog,代码行数:10,代码来源:MainWindow.cpp

示例5: moveUp

void ManageUserDirectories::moveUp() {
  QListWidget *list = listWidget();
  QList<QListWidgetItem *> selected = list->selectedItems();
  for (int i = 0; i < selected.size(); i++) {
    int index = list->row(selected[i]);
    if (index != 0) {
      QListWidgetItem *move = list->takeItem(index);
      list->insertItem(index - 1, move);
    }
    list->setCurrentItem(selected[i]);
  }
}
开发者ID:DanNixon,项目名称:mantid,代码行数:12,代码来源:ManageUserDirectories.cpp

示例6: selectPrev

void AnimationDialog::selectPrev()
{
    m_kfi->stopInterpolation();
    QListWidget* list = m_ui->listWidget;
    int prev =  list->row(m_item) - 1;
    if( !(prev >= 0 && list->count()) )
    {
        prev = 0;
    }

    AnimationListItem* item = static_cast<AnimationListItem*>(list->item(prev));
    list->setCurrentItem(item);
    m_item = item;
    m_parent->camera()->interpolateTo(m_item->frame(), 0.5);
}
开发者ID:Degot,项目名称:Las-Vegas-Reconstruction,代码行数:15,代码来源:AnimationDialog.cpp

示例7: selectNext

void AnimationDialog::selectNext()
{
    m_kfi->stopInterpolation();
    QListWidget* list = m_ui->listWidget;
    int next =  list->row(m_item) + 1;
    if(next > list->count() - 1)
    {
        next = list->count() - 1;
    }

    AnimationListItem* item = static_cast<AnimationListItem*>(list->item(next));
    list->setCurrentItem(item);
    m_item = item;
    m_parent->camera()->interpolateTo(m_item->frame(), 0.5);
}
开发者ID:Degot,项目名称:Las-Vegas-Reconstruction,代码行数:15,代码来源:AnimationDialog.cpp

示例8: AddFilter

void OBSBasicFilters::AddFilter(OBSSource filter)
{
	uint32_t flags = obs_source_get_output_flags(filter);
	bool async = (flags & OBS_SOURCE_ASYNC) != 0;
	QListWidget *list = async ? ui->asyncFilters : ui->effectFilters;

	QListWidgetItem *item = new QListWidgetItem();
	Qt::ItemFlags itemFlags = item->flags();

	item->setFlags(itemFlags | Qt::ItemIsEditable);
	item->setData(Qt::UserRole, QVariant::fromValue(filter));

	list->addItem(item);
	list->setCurrentItem(item);
	SetupVisibilityItem(list, item, filter);
}
开发者ID:Kalreg,项目名称:obs-studio,代码行数:16,代码来源:window-basic-filters.cpp

示例9: moveModule

void SettingsWidget::moveModule()
{
	if (QToolButton *tB = qobject_cast<QToolButton *>(sender()))
	{
		const bool moveDown = tB->arrowType() == Qt::DownArrow;
		const int idx = tB->property("idx").toInt();
		QListWidget *mL = page2ModulesList[idx]->list;
		int row = mL->currentRow();
		if (row > -1)
		{
			QListWidgetItem *item = mL->takeItem(row);
			mL->clearSelection();
			if (moveDown)
				++row;
			else
				--row;
			mL->insertItem(row, item);
			mL->setCurrentItem(item);
		}
	}
}
开发者ID:arthurzam,项目名称:QMPlay2,代码行数:21,代码来源:SettingsWidget.cpp


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