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


C++ QTreeWidgetItem::insertChildren方法代码示例

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


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

示例1: insertChildren

void QTreeWidgetItemProto::insertChildren(int index, const QList<QTreeWidgetItem *> &children)
{
  QTreeWidgetItem *item = qscriptvalue_cast<QTreeWidgetItem*>(thisObject());
  if (item)
    item->insertChildren(index, children);
}
开发者ID:,项目名称:,代码行数:6,代码来源:

示例2: dropEvent

void CBookmarkIndex::dropEvent( QDropEvent* event ) {
    qDebug() << "CBookmarkIndex::dropEvent";

    //setState(QAbstractItemView::NoState);
    // Try to prevent annoying timed autocollapsing. Remember to disconnect before return.
    QObject::connect(this, SIGNAL(itemCollapsed(QTreeWidgetItem*)), this, SLOT(expandAutoCollapsedItem(QTreeWidgetItem*)));
    QTreeWidgetItem* item = itemAt(event->pos());
    QTreeWidgetItem* parentItem = 0;
    int indexUnderParent = 0;

    // Find the place where the drag is dropped
    if (item) {
        qDebug() << "there was item";

        QRect rect = visualItemRect(item);
        bool isFolder = dynamic_cast<BtBookmarkFolder*>(item);
        bool isBookmark = dynamic_cast<BtBookmarkItem*>(item);

        if (isFolder) { // item is a folder
            qDebug() << "item was folder";
            if (event->pos().y() > rect.bottom() - (2* rect.height() / 3) ) {
                parentItem = item;
            }
            else {
                parentItem = item->parent();
                if (!parentItem) {
                    parentItem = invisibleRootItem();
                }
                qDebug() << "item:" << item << "parent:" << parentItem;
                indexUnderParent = parentItem->indexOfChild(item); // before the current folder
            }
        }
        else {
            if (isBookmark) { // item is a bookmark
                qDebug() << "item was bookmark";
                parentItem = item->parent();
                if (!parentItem) {
                    parentItem = invisibleRootItem();
                }
                indexUnderParent = parentItem->indexOfChild(item); // before the current bookmark
                if (event->pos().y() > rect.bottom() - rect.height() / 2) {
                    indexUnderParent++; // after the current bookmark
                }
            }
            else { // item is the extra item
                parentItem = item->parent();
                if (!parentItem) {
                    parentItem = invisibleRootItem();
                }
                indexUnderParent = parentItem->indexOfChild(item); // before the current bookmark
            }
        }

    }
    else { // no item under event point: drop to the end
        qDebug() << "there was no item";
        parentItem = invisibleRootItem();
        indexUnderParent = parentItem->childCount() - 1;
    }


    if ( event->source() == this ) {
        qDebug() << "dropping internal drag";
        event->accept();

        bool bookmarksOnly = true;
        bool targetIncluded = false;
        bool moreThanOneFolder = false;

        QList<QTreeWidgetItem*> newItems = addItemsToDropTree(parentItem, bookmarksOnly, targetIncluded, moreThanOneFolder);

        if (moreThanOneFolder) {
            QToolTip::showText(QCursor::pos(), tr("Can drop only bookmarks or one folder"));
            QObject::disconnect(this, SIGNAL(itemCollapsed(QTreeWidgetItem*)), this, SLOT(expandAutoCollapsedItem(QTreeWidgetItem*)));
            return;
        }
        if (targetIncluded) {
            QToolTip::showText(QCursor::pos(), tr("Can't drop folder into the folder itself or into its subfolder"));
            QObject::disconnect(this, SIGNAL(itemCollapsed(QTreeWidgetItem*)), this, SLOT(expandAutoCollapsedItem(QTreeWidgetItem*)));
            return;
        }
        // Ask whether to copy or move with a popup menu

        QMenu* dropPopupMenu = new QMenu(this);
        QAction* copy = dropPopupMenu->addAction(tr("Copy"));
        QAction* move = dropPopupMenu->addAction(tr("Move"));
        QAction* dropAction = dropPopupMenu->exec(QCursor::pos());
        if (dropAction == copy) {
            qDebug() << "copy";
            parentItem->insertChildren(indexUnderParent, newItems);
            // Need this here because the "move" case goes through
            // "deleteEntries" which has a save call.
            needToSaveBookmarks();
        }
        else {
            if (dropAction == move) {
                qDebug() << "move";
                parentItem->insertChildren(indexUnderParent, newItems);
                deleteEntries(false);
            }
//.........这里部分代码省略.........
开发者ID:bibletime,项目名称:historic-bibletime-svn,代码行数:101,代码来源:cbookmarkindex.cpp

示例3: GetBaseFileMapinfo

bool MyMainWindow::GetBaseFileMapinfo(QString filename)
{
  //to get image infomation. flag 1 is base image and 2 warp image
  treeBaseItem->setText(0,filename);
  int n=pBaseFileDataset->GetRasterCount();
  //to construct n treewidgetiterm
  QList<QTreeWidgetItem *> items;
  QTreeWidgetItem *p;
  for (int i = 0; i < n; ++i)
    {
      p=new QTreeWidgetItem();
      //get raster band information£»
      GDALRasterBand *poBand=pBaseFileDataset->GetRasterBand(i+1);
      char *poBandDescription=new char[100];
      const char* ptemp=poBand->GetDescription();
      strcpy(poBandDescription,ptemp);
      QString poDes=QString(QLatin1String(poBandDescription));
      p->setText(0,poDes);
      if (sizeof(*ptemp)<2)
	p->setText(0,QString("layer %0").arg(i+1));
      items.append(p);
      treeBaseLayerItem.append(p);
      delete[] poBandDescription;
    }

  p=new QTreeWidgetItem();
  QString str="Map Info";
  p->setText(0,str);
  items.append(p);
  treeBaseItem->insertChildren(0,items);

  items.clear();
  //to get projection
  const char* strchr=pBaseFileDataset->GetProjectionRef();
  char* strchr1=new char[100];
  memcpy(strchr1,strchr,100);
  QTreeWidgetItem *q=new QTreeWidgetItem();
  QString poDes2=QString(QLatin1String(strchr1));
  q->setText(0,poDes2);
  items.append(q);
  treeBaseMapinfoItem=q;
  delete[] strchr1;

  double adfGeoTransform[6];
  pBaseFileDataset->GetGeoTransform( adfGeoTransform );
  strchr1=new char[100];
  sprintf(strchr1,"Pixel: %f",adfGeoTransform[1]);
  QString poDes3=QString(QLatin1String(strchr1));
  q=new QTreeWidgetItem();
  q->setText(0,poDes3);
  items.append(q);
  delete[] strchr1;

  strchr1=new char[100];	
  sprintf(strchr1,"UL X: %.2f",adfGeoTransform[0]);
  QString poDes4=QString(QLatin1String(strchr1));
  q=new QTreeWidgetItem();
  q->setText(0,poDes4);
  items.append(q);
  delete[] strchr1;

  strchr1=new char[100];
  sprintf(strchr1,"UL Y: %.2f",adfGeoTransform[3]);
  QString poDes5=QString(QLatin1String(strchr1));
  q=new QTreeWidgetItem();
  q->setText(0,poDes5);
  items.append(q);
  delete[] strchr1;

  p->insertChildren(0,items);
  return true;
}
开发者ID:junwangcas,项目名称:QT_RS_GUI,代码行数:72,代码来源:mymainwindow.cpp


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