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


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

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


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

示例1: formChannelList

void MainWindow::formChannelList(){

    if (m_availableChannelsQuery->getChannels().size() == 0 ) return;
    else
    {
        m_availableChannels = m_availableChannelsQuery->getChannels();
    }

    m_subscribedChannels = m_subscribedChannelsQuery->getChannels();

    QListWidget * listWidget = ui->channelsListWidget;
    QListWidget * subscribedListWidget = ui->subscribedListWidget;

    // Tab - channels
    while(listWidget->count()>0)
    {
      listWidget->takeItem(0);
    }

    foreach (Channel s, m_availableChannels){
        QListWidgetItem * item = new QListWidgetItem(s.getName());
        if (isSubscribed(s.getName())){
            item->setBackgroundColor(Qt::lightGray);
        }

        listWidget->addItem(item);
    }
开发者ID:4ukuta,项目名称:core,代码行数:27,代码来源:mainwindow.cpp

示例2:

dmz::V8Value
dmz::JsModuleUiV8QtBasic::_list_widget_take_item (const v8::Arguments &Args) {

   v8::HandleScope scope;
   V8Value result = v8::Undefined ();

   JsModuleUiV8QtBasic *self = _to_self (Args);
   if (self) {

      QListWidget *lw = self->v8_to_qobject<QListWidget> (Args.This ());
      if (lw) {

         if (Args.Length ()) {

            QListWidgetItem *item = self->_to_qlistwidgetitem (Args[0]);
            if (item) {

               item = lw->takeItem (lw->row (item));
               if (item) {

                  result = self->create_v8_qlistwidgetitem (item);
               }
            }
         }
      }
   }

   return scope.Close (result);
}
开发者ID:rharder,项目名称:js,代码行数:29,代码来源:dmzJsModuleUiV8QtBasicListWidget.cpp

示例3: undo

void HistoryLog::undo()
{
	int size = ui->HistoryLogList->count();
	if(size > 0)
	{
		QString last = historyLog.back();
		QListWidgetItem* it = ui->HistoryLogList->takeItem(size-1);
		delete it;
		QStringList pieces = last.split( ":" );
		QString itemPiece = pieces[0].mid(0,pieces[0].count()-4).trimmed();
		QString fromPiece = pieces[1].mid(0,pieces[1].count()-4).trimmed();
		QString toPiece = pieces[2].trimmed();
		QListWidget* from = findWidgetByName(fromPiece);
		QListWidget* to = findWidgetByName(toPiece);
		QListWidgetItem* item;
		for(int idx = 0; idx< to->count(); idx++)
		{
			if(to->item(idx)->text() == itemPiece)
			{
				item = to->takeItem(idx);
				from->addItem(item);
				break;
			}
		}
		historyLog.erase(historyLog.end()-1);
	}
}
开发者ID:FrankZZ,项目名称:AvanScrum,代码行数:27,代码来源:HistoryLog.cpp

示例4: btnDownClicked

void CQReportDefinition::btnDownClicked()
{
    QListWidget * pList = static_cast< QListWidget * >(mpReportSectionTab->currentPage());
    int i, imax, to, multipleSelection;

    QListWidgetItem * pMove;

    // Find the index of the first selected item.
    for (i = 0, imax = pList->count(), to = -1, multipleSelection = 0; i < imax; i++)
        if (pList->item(i)->isSelected())
        {
            if (multipleSelection == 0) to = i;

            multipleSelection++;
        }
        else if (multipleSelection > 0)
        {
            pMove = pList->takeItem(i);

            if (pMove)
            {
                pList->insertItem(to, pMove);

                multipleSelection = 0;
                mChanged = true;
            }
        }

    // Unselect things we can not move.
    for (i = pList->count() - multipleSelection, imax = pList->count(); i < imax; i++)
        pList->item(i)->setSelected(false);

    return;
}
开发者ID:sachiinb,项目名称:COPASI,代码行数:34,代码来源:CQReportDefinition.cpp

示例5:

void
PreferencesDialog::moveSelectedListWidgetItems(QListWidget &from,
                                               QListWidget &to) {
  for (auto const &item : from.selectedItems()) {
    auto actualItem = from.takeItem(from.row(item));
    if (actualItem)
      to.addItem(actualItem);
  }
}
开发者ID:b2kguga,项目名称:mkvtoolnix,代码行数:9,代码来源:preferences_dialog.cpp

示例6: removeBuilding

void LairTool::removeBuilding() {
    QListWidget* list = getCurrentBuildingList();

    if (list == NULL)
        return;

    int idx = list->currentRow();

    delete list->takeItem(idx);
}
开发者ID:Mesagoppinmypants,项目名称:Tools,代码行数:10,代码来源:lairtool.cpp

示例7: 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

示例8: 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

示例9: ProcessRemoved

void MainWindow::ProcessRemoved(Process* _process)
{
  QListWidgetItem* item = this->GetProcessItem(_process);
  QListWidget*     list = this->ui.procListWidget;
  if(item != NULL)
      delete list->takeItem(list->row(item));

  if (list->count() == 0x00)
    this->ResetUI();
  else
    list->setCurrentRow(0x00);
}
开发者ID:dpsm,项目名称:pwatchdog,代码行数:12,代码来源:MainWindow.cpp

示例10: onPushButtonUpClicked

void ItemOrderList::onPushButtonUpClicked()
{
    QListWidget *list = ui->listWidgetItems;
    const int row = list->currentRow();
    if (row < 1)
        return;

    list->blockSignals(true);
    list->insertItem(row - 1, list->takeItem(row));
    list->setCurrentRow(row - 1);
    list->blockSignals(false);
}
开发者ID:amosbird,项目名称:CopyQ,代码行数:12,代码来源:itemorderlist.cpp

示例11: on_pushButtonDown_clicked

void ItemOrderList::on_pushButtonDown_clicked()
{
    QListWidget *list = ui->listWidgetItems;
    const int row = list->currentRow();
    if (row < 0 || row == list->count() - 1)
        return;

    list->blockSignals(true);
    list->insertItem(row + 1, list->takeItem(row));
    list->setCurrentRow(row + 1);
    list->blockSignals(false);
}
开发者ID:DINKIN,项目名称:CopyQ,代码行数:12,代码来源:itemorderlist.cpp

示例12: on_removeVesselPushButton_clicked

void MainWindow::on_removeVesselPushButton_clicked()
{
    QListWidget* injectionList = findChild<QListWidget*>("InjectableVesselsListView");
    QListWidget* savesList = findChild<QListWidget*>("vesselsInSaveListView");

    QList<QListWidgetItem*> selected = savesList->selectedItems();

    for(QList<QListWidgetItem*>::Iterator it = selected.begin(); it != selected.end(); it++)
    {
        QListWidgetItem* item = (*it);
        savesList->takeItem(savesList->row(item));
        injectionList->addItem(item);
    }
}
开发者ID:DaymareDev,项目名称:KSPS3,代码行数:14,代码来源:mainwindow.cpp

示例13: on_deleteButton_clicked

void MainWindow::on_deleteButton_clicked()
{
    QListWidget *list = ui->taskList;
    for (QListWidgetItem *item : list->selectedItems())
    {
        bool hasId = false;
        int id = item->data(Qt::UserRole).toInt(&hasId);
        if (hasId)
        {
            deleteTask(id);
        }
        list->takeItem(list->row(item));
        delete item;
    }
}
开发者ID:cl0ne,项目名称:kpi-educational-tasks,代码行数:15,代码来源:mainwindow.cpp

示例14: removeLocalContact

/**
 * Removes a peer from the list of contacts.
 * @brief MainWindow::removeLocalContact
 * @param p Peer to remove
 * @return true if found and deleted
 */
bool MainWindow::removeLocalContact(Peer* p)
{
    QListWidget* list =  ui->lstContacts;
    QString str(p->getName() + "/" + p->getIp());

    for (int i = 0; i < list->count(); ++i)
    {
        if (list->item(i)->data(Qt::DisplayRole).toString().compare(str) == 0)
        {
            delete (list->takeItem(i));
            return true;
        }
    }
    return false;
}
开发者ID:s176251,项目名称:cpp_prosjekt_2014,代码行数:21,代码来源:mainwindow.cpp

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