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


C++ QList::replace方法代码示例

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


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

示例1: sortOurPlayers

void Knowledge::sortOurPlayers(QList<int> &players, Vector2D point, bool ascending)
{
    if( ascending )
    {
        for(int i=0;i<players.size();i++)
        {
            for(int j=i;j<players.size();j++)
            {
                if( (_wm->ourRobot[players.at(j)].pos.loc - point).length()
                        < (_wm->ourRobot[players.at(i)].pos.loc - point).length() )
                {
                    int tmp = players.at(i);
                    players.replace(i,players.at(j));
                    players.replace(j,tmp);
                }
            }
        }
    }
    else
    {
        for(int i=0;i<players.size();i++)
        {
            for(int j=i;j<players.size();j++)
            {
                if( (_wm->ourRobot[players.at(j)].pos.loc - point).length()
                        > (_wm->ourRobot[players.at(i)].pos.loc - point).length() )
                {
                    int tmp = players.at(i);
                    players.replace(i,players.at(j));
                    players.replace(j,tmp);
                }
            }
        }
    }
}
开发者ID:mohsen-raoufi,项目名称:Guidance,代码行数:35,代码来源:knowledge.cpp

示例2:

BezierCurve::BezierCurve(QList<QPointF> pointList, QList<qreal> pressureList, double tol) {
	int n = pointList.size();
	
	// Simplify path
	QList<bool> markList;
	for(int i=0; i<n;i++) { markList.append(false); }
	markList.replace(0, true);
	markList.replace(n-1, true);
	BezierCurve::simplify(tol, pointList, 0, n-1, markList);
	
	QList<QPointF> simplifiedPointList;
	QList<qreal> simplifiedPressureList;
	for(int i=0; i<n;i++) {
		if(markList.at(i)==true)  {
			simplifiedPointList.append(pointList.at(i));
			if(pressureList.size() > i) {
				simplifiedPressureList.append(pressureList.at(i));
			} else {
				simplifiedPressureList.append(0.5); // default pressure
			}
		} 
	}
	
	//pointList = simplifiedPointList;
	//pressureList = simplifiedPressureList;
	//n = pointList.size();
	
	// Create curve from the simplified path
	createCurve(simplifiedPointList, simplifiedPressureList);
	
	//createCurve(pointList, pressureList);
}
开发者ID:Conicer,项目名称:pencil,代码行数:32,代码来源:beziercurve.cpp

示例3: recomputeSizes

void medViewContainerSplitter::recomputeSizes(int requestIndex, int newIndex, int newSize)
{
    if(requestIndex < 0 || newIndex < 0)
        return;

    QList <int> newSizes = this->sizes();
    if(requestIndex >= newSizes.size() || newIndex >= newSizes.size())
        return;

    newSizes.replace(requestIndex, newSize);
    newSizes.replace(newIndex, newSize);
    this->setSizes(newSizes);
}
开发者ID:medInria,项目名称:medInria-public,代码行数:13,代码来源:medViewContainerSplitter.cpp

示例4: closePluginHost

//needs handling if we should delete the plugins or not and save there content
void RackWindow::closePluginHost(QWidget *pluginHost)
{
    RSplitter *splitter = qobject_cast<RSplitter *>(pluginHost->parent());
    RSplitter *parentSplitter = qobject_cast<RSplitter *>(splitter->parent());
    if (!parentSplitter && splitter->count() == 1) return;
    if (splitter->count() > 2)
    {
        QList<int> widgetsizes = splitter->sizes();
        int senderpos = splitter->indexOf(pluginHost);
        if (senderpos == widgetsizes.count()-1)
        {
            widgetsizes.replace(senderpos-1, widgetsizes.at(senderpos-1) + widgetsizes.at(senderpos));
        }
        else
        {
            widgetsizes.replace(senderpos, widgetsizes.at(senderpos) + widgetsizes.at(senderpos+1));
            widgetsizes.removeAt(senderpos + 1);
        }
        delete pluginHost->property("pluginToolBar").value<QToolBar *>();
        pluginHost->setProperty("pluginToolBar", 0);
        delete pluginHost;
        pluginHost = 0;
        splitter->setSizes(widgetsizes);
    }
    else {
        delete pluginHost->property("pluginToolBar").value<QToolBar *>();
        pluginHost->setProperty("pluginToolBar", 0);
        delete pluginHost;
        pluginHost = 0;
    }
    if (splitter->count()==1 && parentSplitter)
    {
        parentSplitter->insertWidget(parentSplitter->indexOf(splitter), splitter->widget(0));
        delete splitter;
        splitter = 0;
    }


    ///test
//    if (m_pluginLoader->unload()) {

//        delete m_pluginLoader;
//        m_pluginLoader = 0;
//        qDebug() << "unloaded";
//    }

    //////////////////

//    QList<RSplitter *> splitters = findChildren<RSplitter *>();
//    qDebug("splitter count: %d", splitters.size());
}
开发者ID:stemuedendron,项目名称:rack-radio-automation-construction-kit,代码行数:52,代码来源:rackwindow.cpp

示例5: scaleMaxAgeTo

// scale data lists from one age to another
void Plant::scaleMaxAgeTo(int age)
{
    double scaleFactor = ((double)age)/((double)this->maxAge);
    Tupel3 newTupel;
    QList<Tupel3> *list;
    for (int i=0; i<dataList.size(); i++) {
        // get list from list of lists
        list = dataList.at(i);
        // rescale all ages in list
        // but remove all tupels that have duplicate age
        int previousAge = -1;
        for (int j=0; j<list->size(); j++) {
            // keep first entry untouched
            if (j==0) {
                previousAge = list->at(j).age;
                continue;
            }
            // get old tupel
            newTupel = list->at(j);
            // set last value to new max age
            if (j==list->size()-1) {
                newTupel.age = age;
                list->replace(j,newTupel);
                // check if previous is duplicate
                // but only if there are more than 2 entries
                if (list->size()>2) {
                    if (list->at(j-1).age==newTupel.age) {
                        list->removeAt(j-1);
                    }
                }
                continue;
            }
            // scale age
            newTupel.age = newTupel.age*scaleFactor;
            // remove old tupel if new age is already in list
            if (newTupel.age==previousAge) {
                list->removeAt(j);
                // remember to decrease counter
                j--;
            } else {
                // replace old tupel with new one
                list->replace(j,newTupel);
            }
        }
    }
    this->maxAge = age;
    this->growthAge = growthAge*scaleFactor;
}
开发者ID:bluepoke,项目名称:glqtree,代码行数:49,代码来源:plant.cpp

示例6: setupAnimation

void LedTests::setupAnimation() {
    QList<Position> gridPositions;
    QList<int> positions;

    int numRows = DEFAULT_NUM_ROWS;
    int numColumns = DEFAULT_NUM_COLUMNS;

    for(int i = 0; i < numColumns; i++) {
        for(int j = 0; j < numRows; j++) {
            gridPositions.append(Position(i, j));
        }
    }

    for(int i = 0; i < numRows * numColumns; i++) {
        positions.append(INVALID);
    }

    int numLeds = gridPositions.count();

    for(int i = 0; i < numLeds; i++) {
        positions.replace((gridPositions.at(i).row()*numColumns) + gridPositions.at(i).column(), i + INITIAL_LED);
    }

    iAnimation->newAnimation(numRows,
                             numColumns,
                             numLeds,
                             positions);
}
开发者ID:annesummers,项目名称:LedAnimator,代码行数:28,代码来源:LedTests.cpp

示例7: debug

void
EqualizerPresets::eqCfgSetPresetVal( const QString &presetName, const QList<int> &presetValues)
{
    DEBUG_BLOCK

    debug() << "Preset:" << presetName << presetValues;

    // Idea is to insert new values into user list
    // if preset exist on the list - replace it values
    const int idUsr = AmarokConfig::equalizerPresetsNames().indexOf( presetName );
    QStringList mNewNames = AmarokConfig::equalizerPresetsNames();
    QList<int> mNewValues = AmarokConfig::equalizerPresestValues();
    debug() << "Old preset found:" << (idUsr >= 0);

    if( idUsr < 0 )
    {
        mNewNames.append( presetName );
        mNewValues += presetValues;
    }
    else
    {
        for( int it = 0; it < NUM_EQ_VALUES; it++ )
            mNewValues.replace( idUsr * NUM_EQ_VALUES + it, presetValues.value(it) );
    }
    AmarokConfig::setEqualizerPresetsNames( mNewNames );
    AmarokConfig::setEqualizerPresestValues( mNewValues );
}
开发者ID:jernejovc,项目名称:amarok-clone,代码行数:27,代码来源:EqualizerPresets.cpp

示例8: DeleteEvent

//Deletes the selected event
void WorkoutWindow::DeleteEvent()
{
    //Removes the selected event from both the list and every athlete after the save button is pressed
    int currentIndex = WorkoutList->currentRow();
    //If there is something in the list
    if (currentIndex != -1)
    {
        //Remove from list
        WorkoutList->takeItem(currentIndex);
        //Remove from all athlete workouts
        for (int i = 0; i < LoadedEvents.size(); i++)
        {
            QList<RunningEvent> currentEvents = LoadedEvents.at(i);
            RunningEvent eventToBeDeleted = currentEvents.at(currentIndex);
            //Ready for it to be deleted from the database
            EventsToBeRemoved.append(eventToBeDeleted);
            //Remove the event
            currentEvents.removeAt(currentIndex);
            //Update the event number of every event after it
            for (int j = currentIndex; j < currentEvents.size(); j++)
            {
                RunningEvent thisEvent = currentEvents.at(j);
                thisEvent.setEventOrderNumber(j);
                currentEvents.replace(j,thisEvent);
            }
            LoadedEvents.replace(i,currentEvents);
        }
    }
}
开发者ID:martina3203,项目名称:MikeysApplication,代码行数:30,代码来源:WorkoutWindow.cpp

示例9: modifyToolBarCommandList

void PhoneCommandExtensionWrapper::modifyToolBarCommandList(
        const QList<XQTelUiCommandExtension::CallInfo> &callInfo,
        QList<XQTelUiCommandExtension::ToolBarCommand> &toolBarCmdList)
{
    if (m_setInvalidToolBarCommands) {
        XQTelUiCommandExtension::ToolBarCommand invalidCommand;
        invalidCommand.mCommandId = -1;
        invalidCommand.mIsEnabled = true;
        toolBarCmdList.replace(0,invalidCommand);
    } else if (m_setCustomToolBarCommands) {
        toolBarCmdList.clear();
        XQTelUiCommandExtension::ToolBarCommand command;
        command.mCommandId = PhoneInCallCmdJoinToConference;
        command.mIsEnabled = true;
        toolBarCmdList.append(command);
        command.mCommandId = PhoneInCallCmdUnhold;
        command.mIsEnabled = true;
        toolBarCmdList.append(command);
        command.mCommandId = PhoneInCallCmdEndOutgoingCall;
        command.mIsEnabled = true;
        toolBarCmdList.append(command);
        command.mCommandId = PhoneCallComingCmdSilent;
        command.mIsEnabled = true;
        toolBarCmdList.append(command);
    }
}
开发者ID:cdaffara,项目名称:symbiandump-ossapps,代码行数:26,代码来源:phonecommandextensionwrapper_stub.cpp

示例10: _delete_triggered

void CMainWindow::_delete_triggered()
{
    QList<QTableWidgetItem*> list = _listMail->selectedItems();
    QList<int> realList;

    for (int i = 0; i < list.size(); ++i)
    {
        if (!realList.contains(list[i]->row()))
            realList.append(list[i]->row());
    }
    qSort(realList.begin(), realList.end());
    for (int i = 0; i < realList.size(); ++i)
    {
        QTableWidgetItem *item = _listMail->item(realList[i], 0);
        try
        {
            _socket->removeMail(qPrintable(item->text()));
            _listMail->removeRow(realList[i]);
            for (int j = i; j < realList.size(); ++j)
                realList.replace(j, realList[j] - 1);
        }
        catch (const std::exception &e)
        {
        QMessageBox::critical(this, "Delete", "Can't delete row " + QString::number(realList[i] + 1));
        }
    }
}
开发者ID:Wayt,项目名称:AnciensProjets,代码行数:27,代码来源:CMainWindow.cpp

示例11: addBusTimes

/*
 * 	addBusTimes method
 * 	Inputs: QDomNode n
 *	Outputs: none
 * 	Takes input of first child in a station (which equals the first time for that child).
 *	Looks through all children for this parent node and find which time and hour values
 *	are after the current time and hour. Adds the next of these to bus time list
 */
void LoadData::addBusTimes(QDomNode n) {
	QStringList k;
	bool ok;
	int j = 0;
	int r, q;
	QDomElement e;
	do {
		k.clear();
		e = n.toElement(); //Get the current node (time) and split by "."
		k = e.text().split(".");
		//qDebug() << e.text();
		r = k[0].toInt(&ok, 10); //Hour
		q = k[1].toInt(&ok, 10); //Minute
		if (r <= 3) //Special case when time is 00, 01, 02 or 03
			r = r + 24;
		if (timeHour <=3)
			timeHour += 24;
		//Add into array if its time is later than the current time
		if (r > timeHour || (r == timeHour && q >= timeMinute)) {
			//buses.at(j)[0] = e.text();
			QStringList temp = buses.at(j);
			temp[0] = e.text();
			buses.replace(j, temp);
			//qDebug() << " Added "  << temp[0];
			j++;
		}
		n = n.nextSibling(); //Go to the next sibling in nodes
		//Stop running loop if you get to null node or you've added 5 buses
		if (j >= 3 || n.isNull())
			break;
	} while (true);
}
开发者ID:git4ric,项目名称:QtProject,代码行数:40,代码来源:LoadData.cpp

示例12: replace

void tst_QList::replace() const
{
    QList<QString> list;
    list << "foo" << "bar" << "baz";

    // start
    list.replace(0, "moo");
    QCOMPARE(list, QList<QString>() << "moo" << "bar" << "baz");

    // middle
    list.replace(1, "cow");
    QCOMPARE(list, QList<QString>() << "moo" << "cow" << "baz");

    // end
    list.replace(2, "milk");
    QCOMPARE(list, QList<QString>() << "moo" << "cow" << "milk");
}
开发者ID:KDE,项目名称:android-qt,代码行数:17,代码来源:tst_qlist.cpp

示例13: setDefaultGraphics

void HbInputButtonPrivate::setDefaultGraphics(int keyCode)
{
    switch(keyCode) {
        case HbInputButton::ButtonKeyCodeDelete:
            mIcons.replace(HbInputButton::ButtonTextIndexPrimary, HbIcon(HbInputButtonIconDelete));
            break;
        case HbInputButton::ButtonKeyCodeShift:
            mIcons.replace(HbInputButton::ButtonTextIndexPrimary, HbIcon(HbInputButtonIconShift));
            break;
        case HbInputButton::ButtonKeyCodeSymbol:
            mIcons.replace(HbInputButton::ButtonTextIndexPrimary, HbIcon(HbInputButtonIconSymbol));
            break;
        case HbInputButton::ButtonKeyCodeEnter:
            mIcons.replace(HbInputButton::ButtonTextIndexPrimary, HbIcon(HbInputButtonIconEnter));
            break;
        case HbInputButton::ButtonKeyCodeSpace:
            mIcons.replace(HbInputButton::ButtonTextIndexPrimary, HbIcon(HbInputButtonIconSpace));
            break;
        case HbInputButton::ButtonKeyCodeAlphabet:
            mIcons.replace(HbInputButton::ButtonTextIndexPrimary, HbIcon(HbInputButtonIconSymbol));
            break;
        case HbInputButton::ButtonKeyCodeSmiley:
            mIcons.replace(HbInputButton::ButtonTextIndexPrimary, HbIcon(HbInputButtonIconSmiley));
            break;
        default:
            break;
    }
}
开发者ID:kuailexs,项目名称:symbiandump-mw1,代码行数:28,代码来源:hbinputbutton.cpp

示例14: hidePreview

void EncodeWidget::hidePreview()
{
    ui->graphicsView->setVisible(false);
    ui->hidePreviewButton->setVisible(false);

    QList<int> sizes = ui->splitter->sizes();
    sizes.replace(1, 0);
    ui->splitter->setSizes(sizes);
}
开发者ID:sadika9,项目名称:Stegy,代码行数:9,代码来源:encodewidget.cpp

示例15: showPreview

void EncodeWidget::showPreview(QString image)
{

    if (image == "CoverPreviewButton")
    {
        ui->graphicsView->scene()->clear();
        QGraphicsPixmapItem *pixItem = new QGraphicsPixmapItem(QPixmap::fromImage(m_coverImage));
        ui->graphicsView->scene()->addItem(pixItem);

        ui->graphicsView->setVisible(true);
        ui->hidePreviewButton->setVisible(true);

        QList<int> sizes = ui->splitter->sizes();
        sizes.replace(1, ui->graphicsView->scene()->width());
        ui->splitter->setSizes(sizes);
    }
    else if (image == "SecretPreviewButton")
    {
        ui->graphicsView->scene()->clear();
        QGraphicsPixmapItem *pixItem = new QGraphicsPixmapItem(QPixmap::fromImage(m_secretImage));
        ui->graphicsView->scene()->addItem(pixItem);

        ui->graphicsView->setVisible(true);
        ui->hidePreviewButton->setVisible(true);

        QList<int> sizes = ui->splitter->sizes();
        sizes.replace(1, ui->graphicsView->scene()->width());
        ui->splitter->setSizes(sizes);
    }
    else if (image == "EncodeButton")
    {
        ui->graphicsView->scene()->clear();
        QGraphicsPixmapItem *pixItem = new QGraphicsPixmapItem(QPixmap::fromImage(m_stegoImage));
        ui->graphicsView->scene()->addItem(pixItem);

        ui->graphicsView->setVisible(true);
        ui->hidePreviewButton->setVisible(true);

        QList<int> sizes = ui->splitter->sizes();
        sizes.replace(1, ui->graphicsView->scene()->width());
        ui->splitter->setSizes(sizes);
    }
}
开发者ID:sadika9,项目名称:Stegy,代码行数:43,代码来源:encodewidget.cpp


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