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


C++ setItem函数代码示例

本文整理汇总了C++中setItem函数的典型用法代码示例。如果您正苦于以下问题:C++ setItem函数的具体用法?C++ setItem怎么用?C++ setItem使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


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

示例1: QStandardItem

void UVSearchModel::addUv(const UV &uv)
{
    //Q_ASSERT(false);
    /*QList<QStandardItem*> newRow;
    newRow.push_back(new QStandardItem(uv.getCode()));
    newRow.push_back(new QStandardItem(uv.getTitre()));
    newRow.push_back(new QStandardItem(UTManager::categorieUVEnumToText(uv.getCategorie())));
    newRow.push_back(new QStandardItem(QString::number(uv.getNombreCredit())));
    newRow.push_back(new QStandardItem("NYI"));
    appendRow(newRow);*/

    int row = rowCount();
    setItem(row, 0, new QStandardItem(uv.getCode()));
    setItem(row, 1, new QStandardItem(uv.getTitre()));
    setItem(row, 2, new QStandardItem(UTManager::categorieUVEnumToText(uv.getCategorie())));
    setItem(row, 3, new QStandardItem(QString::number(uv.getNombreCredit())));
    setItem(row, 4, new QStandardItem("NYI"));
}
开发者ID:Shiroy,项目名称:utprofiler,代码行数:18,代码来源:uvsearchmodel.cpp

示例2: setItem

void Table::clearContents()
{
    // We need to create new cells upon clearing
    for(int i=0; i < rowCount(); i++)
    {
        for(int j=0; j < columnCount(); j++)
            setItem(i, j, new Cell(""));
    }
}
开发者ID:fundies,项目名称:PolyEditQT,代码行数:9,代码来源:table.cpp

示例3: PRECONDITION

void InnerNode::addElt( Item& itm, int at )
{
    PRECONDITION( 0 <= at && at <= last+1 );
    PRECONDITION( last < maxIndex() );
    for( int i = last+1; i > at ; i-- )
        getItem(i) = getItem(i-1);
    setItem( at, itm );
    last++;
}
开发者ID:WiLLStenico,项目名称:TestesEOutrasBrincadeiras,代码行数:9,代码来源:btreeinn.cpp

示例4: cell

void SpreadSheet::setFormula(int row, int column, const QString &formula)
{
    Cell *c = cell(row, column);
    if(!c){
        c = new Cell;
        setItem(row, column, c);
    }
    c->setFormula(formula);
}
开发者ID:marsimunovic,项目名称:QTGui,代码行数:9,代码来源:spreadsheet.cpp

示例5: setRowCount

/** should be called in constructor for basic setup of 
 * table cells.
 */
void RatingsTable::setupCells()
{
  PlayerList players = _group->const_players();
  int plCnt = players.count();
  setRowCount( plCnt + 1 );
  setColumnCount( plCnt + 1 + 1 ); // 1 column for total rating results

  for ( int i = 0; i < rowCount(); i ++ ) {
    for ( int j = 0; j < plCnt + 1; j ++ ) {
      QTableWidgetItem *item = new QTableWidgetItem( );
      QString text;
      if ( i == j ) {
        item->setBackground( palette().brush( QPalette::Disabled,
                                              QPalette::Background ) );
        
        if ( i == 0 )  {
          text = _group->name();
        }
        item->setFlags( Qt::NoItemFlags );
      } else if ( i == 0 ) { // 0th row
        text = players.at( j - 1 ).name();
        item->setFlags( Qt::NoItemFlags );
      } else if ( j == 0 ) { // 0th column
        Player p = players.at( i - 1 );
        text = p.name();
        text += " (" + QString::number( p.rating(), 'f', 1 ) + ")";
        item->setFlags( Qt::NoItemFlags );
      } else {
        item->setFlags( Qt::ItemIsSelectable | Qt::ItemIsEnabled );
      }

      item->setText( text );

      setItem( i, j, item );
    }
  
    QTableWidgetItem *item = new QTableWidgetItem( );
    if ( i == 0 ) {
      item->setText( tr( "New rating" ) );
    }
    item->setFlags( Qt::NoItemFlags );
    setItem( i, plCnt + 1, item );
  }
}
开发者ID:kiff20072008,项目名称:tournament,代码行数:47,代码来源:ratingstable.cpp

示例6: updateItemQuantityCache

bool Player::setItemInFreeSlot(size_t invIdx, std::unique_ptr<Item>& item,
	InventoryPosition invPos, bool splitIntoMultiple)
{
	if (invIdx < inventories.size())
	{
		auto& inventory = inventories[invIdx];

		// if item has the quantity/capacity peoperties
		if (item != nullptr &&
			item->hasIntByHash(ItemProp::Capacity) == true)
		{
			// first, try and fit the item into the smallest existing item of the same class
			auto quantityNeeded = item->getIntByHash(ItemProp::Quantity);
			Item* quantItem;
			if (inventory.findBiggestFreeQuantity(
				item->Class()->IdHash16(), quantItem, quantityNeeded) > 0)
			{
				LevelObjValue transferedQuantity;
				if (Inventory::updateQuantities(
					quantItem, item.get(), transferedQuantity, true) == true)
				{
					updateItemQuantityCache(item->Class()->IdHash16(), transferedQuantity);
					return true;
				}
			}

			// if SplitIntoMultiple is true, try and add to all free items
			// and create new items, if possible (should not create more then 1 item)
			if (splitIntoMultiple == true)
			{
				// add full quantity
				LevelObjValue itemSlots;
				auto freeSlots = inventory.getMaxCapacity(*item->Class());
				if (item->getIntByHash(ItemProp::Quantity, itemSlots) == true &&
					itemSlots >= 0 &&
					(unsigned)itemSlots <= freeSlots)
				{
					inventory.addQuantity(*item->Class(), itemSlots, invPos, this);
					updateItemQuantityCache(item->Class()->IdHash16(), itemSlots);
					return true;
				}
				// if you can't add all of it, add none and return.
				return false;
			}
			// if it doesn't fit into the smallest, try and add it in a free slot
		}

		// try and add item to free slot
		size_t itemIdx = 0;
		if (inventory.getFreeSlot(*item, itemIdx, invPos) == true)
		{
			return setItem(invIdx, itemIdx, item);
		}
	}
	return false;
}
开发者ID:dgengin,项目名称:DGEngine,代码行数:56,代码来源:Player.cpp

示例7: currentItem

/** Move the selected track downward. */
void Playlist::moveTrackDown()
{
	if (currentItem()) {
		int currentRow = currentItem()->row();
		if (currentRow < rowCount()-1) {
			for (int c=0; c < columnCount(); c++) {
				QTableWidgetItem *currentItem = takeItem(currentRow, c);
				QTableWidgetItem *nextItem = takeItem(currentRow+1, c);
				setItem(currentRow, c, nextItem);
				setItem(currentRow+1, c, currentItem);
			}
			sources.swap(currentRow, currentRow+1);
			this->setCurrentIndex(model()->index(currentRow+1, 0));
			if (currentRow == track) {
				track++;
			}
		}
	}
}
开发者ID:GothCodeMonkey,项目名称:Madame-Miam-Miam-Music-Player,代码行数:20,代码来源:playlist.cpp

示例8: QStandardItemModel

void LC_DlgSplinePoints::updatePoints()
{
    bool const useSpline = ui->rbSplinePoints->isChecked();

    auto const& bData = bezier->getData();
    auto const& pts = useSpline?bData.splinePoints:bData.controlPoints;
    auto model = new QStandardItemModel(pts.size(), 2, this);
    model->setHorizontalHeaderLabels({"x", "y"});

    //set spline data
    for (size_t row = 0; row < pts.size(); ++row) {
        auto const& vp = pts.at(row);
        QStandardItem* x = new QStandardItem(QString::number(vp.x));
        model->setItem(row, 0, x);
        QStandardItem* y = new QStandardItem(QString::number(vp.y));
        model->setItem(row, 1, y);
    }
    ui->tvPoints->setModel(model);
}
开发者ID:tytower,项目名称:LibreCAD,代码行数:19,代码来源:lc_dlgsplinepoints.cpp

示例9: doClear

void PartsBinView::setPaletteModel(PaletteModel * model, bool clear) {
	if (clear) {
		doClear();
	}

	if (model->root() == NULL) return;

	setItemAux(model->root());
	setItem(model->root());
}
开发者ID:Ipallis,项目名称:Fritzing,代码行数:10,代码来源:partsbinview.cpp

示例10: addPreview

    void addPreview(QUrl previewfile)
    {
        QTableWidgetItem *previewitem = new QTableWidgetItem();
        previewitem->setSizeHint(QSize(64, 64));
        previewitem->setIcon(QIcon(previewfile.path()));

        setItem(m_previewentries, 4, previewitem);
        m_previewentries++;
        // FIXME: mapping from entry to url and to vertical position(s)
    }
开发者ID:KDE,项目名称:knewstuff,代码行数:10,代码来源:knewstuff2_download.cpp

示例11: setRowCount

void WorkflowView::showItem(const QList<QString> & items)
{
	// Setting row count to zero destroys all rows
	setRowCount(0);

    for(int i = 0; i < items.count(); i+=2) {
        int newRow = rowCount();
        insertRow(newRow);
        QTableWidgetItem *variable = new QTableWidgetItem;
        QTableWidgetItem *value = new QTableWidgetItem;
        variable->setText(items[i]);
        value->setText(items[i+1]);
        setItem(newRow, 0, variable);
        setItem(newRow, 1, value);
    }

	// Insert the last empty row for custom info
	insertRow(rowCount());
}
开发者ID:puzzleSEQ,项目名称:client,代码行数:19,代码来源:WorkflowView.cpp

示例12: MyItem

ZoneItem::ZoneItem (QGraphicsScene *scene, TriggerItem *parent, int x, int y, int w, int h) :
    MyItem (NULL, ""),
    m_parent (parent)
{
    Q_UNUSED (scene);
    m_width = w;
    m_height = h;
    setItem (addRect (0, 0, m_width, m_height) );
    setPos (x, y);
}
开发者ID:joetde,项目名称:SuperBadbar,代码行数:10,代码来源:ZoneItem.cpp

示例13: setRowCount

void NShortcutEditorWidget::init(const QList<NAction *> &actionList)
{
    if (m_init)
        return;
    m_init = true;

    m_actionList = actionList;
    setRowCount(m_actionList.size());
    for (int i = 0; i < m_actionList.size(); ++i) {
        NAction *action = m_actionList.at(i);

        QTableWidgetItem *nameItem = new QTableWidgetItem(action->text());
        nameItem->setFlags(Qt::NoItemFlags);
        nameItem->setData(Qt::UserRole, action->objectName());
        setItem(i, Name, nameItem);

        QTableWidgetItem *descriptionItem = new QTableWidgetItem(action->statusTip());
        descriptionItem->setFlags(Qt::NoItemFlags);
        setItem(i, Description, descriptionItem);

        QList<QKeySequence> shortcut = action->shortcuts();
        QStringList shortcutStr;
        foreach (QKeySequence seq, shortcut)
            shortcutStr << seq.toString();
        QTableWidgetItem *shortcutItem = new QTableWidgetItem(shortcutStr.join(", "));
        setItem(i, Shortcut, shortcutItem);

        QList<QKeySequence> globalShortcut = action->globalShortcuts();
        QStringList globalShortcutStr;
        foreach (QKeySequence seq, globalShortcut)
            globalShortcutStr << seq.toString();
        QTableWidgetItem *globalShortcutItem = new QTableWidgetItem(globalShortcutStr.join(", "));
        setItem(i, GlobalShortcut, globalShortcutItem);
    }

    resizeColumnToContents(Name);
    resizeColumnToContents(Description);
    horizontalHeader()->setResizeMode(Name, QHeaderView::Fixed);
    horizontalHeader()->setResizeMode(Description, QHeaderView::Fixed);
    horizontalHeader()->setResizeMode(Shortcut, QHeaderView::Stretch);
    horizontalHeader()->setResizeMode(GlobalShortcut, QHeaderView::Stretch);
    horizontalHeader()->setStretchLastSection(true);
}
开发者ID:nulloy,项目名称:nulloy,代码行数:43,代码来源:shortcutEditorWidget.cpp

示例14: item

void ViewTableListWidget::sortByFrequencyCustom(bool ascend)
{
    QList<SortItem> list;
    for(int i = 0; i < rowCount(); i++)
    {
        SortItem newitem;
        newitem.row = i;
        newitem.frequecy = item(i,2)->text().toInt();
        int j = 0;
        if(ascend)
            for(j = list.count() - 1; j >=0 ; j--)
            {
                if(newitem.frequecy >= list.at(j).frequecy) break;
            }
        else
            for(j = list.count() - 1; j >=0 ; j--)
            {
                if(newitem.frequecy <= list.at(j).frequecy) break;
            }
        list.insert(j + 1,newitem);
    }
    QTableWidgetItem * tempitem;
    int temprowcount = rowCount();
    for(int i = 0; i < temprowcount; i++)
    {
        this->insertRow(temprowcount + i);
        tempitem = new QTableWidgetItem(item(list.at(i).row,0)->text());
        tempitem->setIcon(item(list.at(i).row,0)->icon());
        tempitem->setToolTip(item(list.at(i).row,0)->toolTip());
        setItem(temprowcount + i,0,tempitem);
        tempitem = new QTableWidgetItem(item(list.at(i).row,1)->text());
        setItem(temprowcount + i,1,tempitem);
        tempitem = new QTableWidgetItem(item(list.at(i).row,2)->text());
        tempitem->setTextAlignment(Qt::AlignCenter);
        setItem(temprowcount + i,2,tempitem);
        tempitem = new QTableWidgetItem(item(list.at(i).row,3)->text());
        tempitem->setTextAlignment(Qt::AlignCenter);
        setItem(temprowcount + i,3,tempitem);
    }
    for(int i = 0; i < temprowcount; i++)
        removeRow(0);
    list.clear();
}
开发者ID:nhosproject,项目名称:OSProject,代码行数:43,代码来源:viewtablelistwidget.cpp

示例15: Tooltip

	TooltipItem::TooltipItem(const Item *item) :
		Tooltip(item),
		mGraphic(new Sprite()),
		mText(new TextField2()),
		mLayer(new Layer())
	{
		init();

		setItem(item);
	}
开发者ID:astrellon,项目名称:Rouge,代码行数:10,代码来源:gfx_tooltip_item.cpp


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