• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ setItem函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


示例16: item

void SharedUiItemWidgetMapper::itemChanged(SharedUiItem newItem,
                                           SharedUiItem oldItem) {
  // refresh mapping on rename or update (newItem contains new id and data)
  // stop following on delete (newItem is null)
  // do nothing on creation (oldItem is null, which cannot == non null _item)
  if (!_item.isNull() // mapper is currently following an item
      && oldItem == _item) { // related to followed item (same qualified id)
    setItem(newItem);
  }
}
开发者ID:g76r,项目名称:libh6ncsu,代码行数:10,代码来源:shareduiitemwidgetmapper.cpp


示例17: QStandardItem

void VarTableModel::update()
{
    static int first_update = 1;

    quint32 index = 0;
    estats_val_data* tmp;
 
    estats::Check(estats_read_vars(newdata, cid, nl_client));

    for (int i = 0; i < newdata->length; i++) {
	ESTATS_VAL_TYPE valtype = estats_var_array[i].valtype;
	ESTATS_TYPE type = estats_var_array[i].type;
	char* valstr;

	estats::Check(estats_val_as_string(&valstr, &newdata->val[i], valtype));

        QStandardItem* item = new QStandardItem(valstr); 
//        QStandardItem* item = new QStandardItem(newdata->val[i]); 
        setItem(index, 1, item);

        free((void*)valstr);

        if (!first_update && (type == ESTATS_TYPE_COUNTER32 || type == ESTATS_TYPE_COUNTER64)) {
            estats::Check(estats_val_data_delta(deldata, newdata, olddata));

	    estats::Check(estats_val_as_string(&valstr, &deldata->val[i], valtype));

            QStandardItem* item = new QStandardItem(valstr);
//            QStandardItem* item = new QStandardItem(QString::number(deldata->val[i]));

            setItem(index, 2, item);

            free((void*)valstr);
        }
	index++;
    }
    tmp = olddata;
    olddata = newdata;
    newdata = tmp;

    if (first_update) first_update = 0;
}
开发者ID:hyjang,项目名称:web10g-userland,代码行数:42,代码来源:var_tablemodel.cpp


示例18: rowCount

void TimerView::addTimer(InsteonTimer timer)
{
	static QString dow[7] = { "S ", "M ", "T ", "W ", "Th ", "F ", "Sa" };
	QString mode;
	QString dowText;

	int row = rowCount() - 1;

	if (row == -1) {
		addBlankRow();
		row = 0;
	}

	insertRow(row);

	setItem(row, 0, new QTableWidgetItem(timer.name));
    if (timer.mode == INSTEON_TIMER_MODE_TOD)
        setItem(row, 1, new QTableWidgetItem(timer.time.toString("hh:mm")));
    else
        setItem(row, 1, new QTableWidgetItem("---"));

	for (int i = 0; i < 7; i++) {
		if (timer.daysOfWeek & (0x01 << i))
			dowText += dow[i];
	}

	setItem(row, 2, new QTableWidgetItem(dowText));

	if (timer.mode == INSTEON_TIMER_MODE_TOD)
		mode = "DOW";
	else if (timer.mode == INSTEON_TIMER_MODE_SUNRISE)
		mode = "Sunrise";
	else if (timer.mode == INSTEON_TIMER_MODE_SUNSET)
		mode = "Sunset";

	setItem(row, 3, new QTableWidgetItem(mode));
	setItem(row, 4, new QTableWidgetItem(QString::number(timer.deltaTime)));
	setItem(row, 5, new QTableWidgetItem(timer.randomMode ? "true" : "false"));
	setItem(row, 6, new QTableWidgetItem(timer.armed ? "true" : "false"));
	setItem(row, 7, new QTableWidgetItem(QString::number(timer.devices.count())));
	setItem(row, 8, new QTableWidgetItem(timer.triggerTime.toString("hh:mm")));
}
开发者ID:carriercomm,项目名称:SyntroHA,代码行数:42,代码来源:TimerView.cpp


示例19: tr

void FileListModel::setPath( const QString &path )
{
    dir.setPath( path );
    if ( !dir.exists() )
    {
        QMessageBox::information( nullptr, tr( "info" ), tr( "Dir Not Exist!" ) );
        return;
    }
    fileInfoHash.clear();
    clear();
    QStringList columnLabels;
    columnLabels.push_back( tr( "Name" ) );
    columnLabels.push_back( tr( "Size" ) );
    columnLabels.push_back( tr( "Kind" ) );
    columnLabels.push_back( tr( "Date Modified" ) );
    setHorizontalHeaderLabels( columnLabels );
    QList<QFileInfo> fileList = dir.entryInfoList();
    int rowCount = 0;
    for ( const QFileInfo &entry : fileList )
    {
        QString fileName = entry.fileName();
        if ( fileName == "." )
        {
            continue;
        }
        QStandardItem *c1 = new QStandardItem( entry.fileName() );
        QStandardItem *c2 = new QStandardItem( QString::number( entry.size() ) );
        c2->setFlags(Qt::ItemIsSelectable);
        QStandardItem *c3 = new QStandardItem( entry.suffix() );
        c3->setFlags(Qt::ItemIsSelectable);
        QStandardItem *c4 = new QStandardItem( entry.lastModified().toString() );
        c4->setFlags(Qt::ItemIsSelectable);

        setItem( rowCount, 0, c1 );
        setItem( rowCount, 1, c2 );
        setItem( rowCount, 2, c3 );
        setItem( rowCount, 3, c4 );

        fileInfoHash.insert( rowCount, entry );
        ++rowCount;
    }
}
开发者ID:Wushaowei001,项目名称:BestCommander,代码行数:42,代码来源:filelistmodel.cpp


示例20: clear

void TableWidget::populateTable(const openstudio::WorkspaceObject& obj)
{
  clear();
  setCurrentCell(0,0);
  setRowCount(1);

  openstudio::IddObject iddObj = obj.iddObject();
  for(unsigned i=0; i<obj.numFields(); ++i){
    bool defaultText = false;
    OptionalString val = obj.getString(i);
    if(!val){
      defaultText = true;
      val = obj.getString(i, true);
      // if still no value it is just blank
      if (!val){
        val = "";
      }
    }
    // setItem causes QTableWIdget to take ownership of newItem
    QTableWidgetItem * newItem = new QTableWidgetItem((*val).c_str());
    if(defaultText){
      newItem->setTextColor(Qt::gray);
    }
    setItem(rowCount()-1, 1, newItem);

    openstudio::OptionalIddField iddField = iddObj.getField(i);
    if(!iddField){
      // log error
    }
    else{
      *val = iddField->name();
    }
    // setItem causes QTableWIdget to take ownership of newItem
    newItem = new QTableWidgetItem((*val).c_str());
    setItem(rowCount()-1, 0, newItem);

    setRowCount(rowCount() + 1);
  }

  resizeColumnsToContents();
  resizeRowsToContents();
}
开发者ID:Anto-F,项目名称:OpenStudio,代码行数:42,代码来源:TableWidget.cpp



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ setItemDelegate函数代码示例发布时间:2022-05-30
下一篇:
C++ setIsChrome函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap