本文整理汇总了C++中QStandardItem::takeChild方法的典型用法代码示例。如果您正苦于以下问题:C++ QStandardItem::takeChild方法的具体用法?C++ QStandardItem::takeChild怎么用?C++ QStandardItem::takeChild使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QStandardItem
的用法示例。
在下文中一共展示了QStandardItem::takeChild方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: takeChild
void tst_QStandardItem::takeChild()
{
QList<QStandardItem*> itemList;
for (int i = 0; i < 10; ++i)
itemList.append(new QStandardItem);
QStandardItem item;
item.appendColumn(itemList);
for (int i = 0; i < item.rowCount(); ++i) {
QCOMPARE(item.takeChild(i), itemList.at(i));
QCOMPARE(item.takeChild(0, 0), static_cast<QStandardItem*>(0));
for (int j = i + 1; j < item.rowCount(); ++j)
QCOMPARE(item.child(j), itemList.at(j));
}
qDeleteAll(itemList);
}
示例2: compare_downloads
void list_handling::compare_downloads(QModelIndex &index, std::vector<package>::iterator &new_it, std::vector<package>::iterator &old_it, vector<view_info> &info){
int dl_line = 0;
vector<download>::iterator old_dit = old_it->dls.begin();
vector<download>::iterator new_dit = new_it->dls.begin();
vector<view_info>::iterator vit;
QStandardItem *pkg;
QStandardItem *dl;
pkg = list_model->itemFromIndex(index);
if(pkg == NULL)
return;
// compare every single download of the package
while((old_dit != old_it->dls.end()) && (new_dit != new_it->dls.end())){
compare_one_download(*new_dit, *old_dit, pkg, dl_line);
// recreate selection if existed
for(vit = info.begin(); vit != info.end(); ++vit){
if((vit->id == new_dit->id) && !(vit->package)){
if(vit->selected){ // download is selected
for(int i=0; i<5; ++i)
selection_model->select(index.child(dl_line, i), QItemSelectionModel::Select);
selected_downloads_size += (double)new_dit->size / 1048576;
++selected_downloads_count;
break;
}
}
}
++old_dit;
++new_dit;
++dl_line;
}
if(old_dit != old_it->dls.end()){ // there are more old lines than new ones
while(old_dit != old_it->dls.end()){
// delete packages out of model
for(int i=0; i<5; ++i){
dl = pkg->takeChild(dl_line, i);
delete dl;
}
pkg->takeRow(dl_line);
++old_dit;
}
}else if(new_dit != new_it->dls.end()){ // there are more new lines than old ones
while(new_dit != new_it->dls.end()){
// insert new download linkes
create_new_download(*new_dit, pkg, dl_line);
++dl_line;
++new_dit;
}
list->collapse(index);
list->expand(index);
}
}