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


C++ QStandardItem::takeChild方法代码示例

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

示例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);
	}
}
开发者ID:HeBD,项目名称:DownloadDaemon,代码行数:60,代码来源:ddclient_gui_list_handling.cpp


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