本文整理汇总了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);
}
示例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);
}
示例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);
}
}
示例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;
}
示例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);
}
}
示例6: removeBuilding
void LairTool::removeBuilding() {
QListWidget* list = getCurrentBuildingList();
if (list == NULL)
return;
int idx = list->currentRow();
delete list->takeItem(idx);
}
示例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 );
}
示例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]);
}
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
}
示例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;
}
}
示例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;
}
示例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);
}
}
}