本文整理汇总了C++中QVector::replace方法的典型用法代码示例。如果您正苦于以下问题:C++ QVector::replace方法的具体用法?C++ QVector::replace怎么用?C++ QVector::replace使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QVector
的用法示例。
在下文中一共展示了QVector::replace方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: QString
/*protected*/ QStringList ImportRollingStock::parseCommaLine(QString line, int arraySize)
{
QVector<QString> outLine = QVector<QString>(arraySize);
if (line.contains("\""))
{ // NOI18N
// log.debug("line number "+lineNum+" has escape char \"");
QStringList parseLine = line.split(",");
int j = 0;
for (int i = 0; i < parseLine.length(); i++)
{
if (parseLine[i].contains("\""))
{ // NOI18N
QString sb = QString(parseLine[i++]);
//sb.deleteCharAt(0); // delete the "
sb.remove(0,1);
outLine.replace(j,sb);
while (i < parseLine.length())
{
if (parseLine[i].contains("\""))
{ // NOI18N
sb = QString(parseLine[i]);
//sb.deleteCharAt(sb.length() - 1); // delete the "
sb.remove(sb.length() - 1,1);
outLine.replace(j,outLine[j] + "," + sb);
// log.debug("generated string: "+outLine[j]);
j++;
break; // done!
}
else
{
outLine.replace(j, outLine[j] + "," + parseLine[i++]);
}
}
}
else
{
// log.debug("outLine: "+parseLine[i]);
outLine.replace(j++, parseLine[i]);
}
if (j > arraySize - 1)
{
break;
}
}
}
else
{
outLine = line.split(",").toVector();
}
return outLine.toList();
}
示例2:
QVector<osg::ref_ptr<Data::Node> >* CameraMath::getViewExtremes( osg::ref_ptr<osg::Camera> camera, std::list<osg::ref_ptr<Data::Node> > selectedCluster )
{
osg::Matrixd mv = camera->getViewMatrix();
osg::Matrixd mp = camera->getProjectionMatrix();
osg::Matrixd mw = camera->getViewport()->computeWindowMatrix();
QVector<osg::ref_ptr<Data::Node> >* extremes = new QVector<osg::ref_ptr<Data::Node> >;
osg::Vec3d leftPosition, rightPosition, topPosition, bottomPosition;
for ( int x = 0; x < 4; x++ ) {
extremes->push_back( selectedCluster.front() );
}
float scale = Util::ApplicationConfig::get()->getValue( "Viewer.Display.NodeDistanceScale" ).toFloat();
osg::Vec3d p = selectedCluster.front()->getCurrentPosition() * scale;
// get initial onscreen position
leftPosition = rightPosition = topPosition = bottomPosition = p * mv * mp * mw;
std::list<osg::ref_ptr<Data::Node> >::iterator i;
// find onscreen extremes in cluster
for ( i = selectedCluster.begin(); i != selectedCluster.end(); ++i ) {
osg::Vec3d position = ( *i )->getCurrentPosition() * scale * mv * mp * mw;
if ( position.x() < leftPosition.x() ) {
extremes->replace( 0, *i );
leftPosition = position;
}
if ( position.x() > rightPosition.x() ) {
extremes->replace( 1, *i );
rightPosition = position;
}
if ( position.y() < topPosition.y() ) {
extremes->replace( 2, *i );
topPosition = position;
}
if ( position.y() > bottomPosition.y() ) {
extremes->replace( 3, *i );
bottomPosition = position;
}
}
return extremes;
}
示例3: createNodes
void SConnections::createNodes(QList<QVector3D>* allNodes, int offset){
qDebug() << "allNodes.length: " << allNodes->length();
qDebug() << "create Nodes in SConnections";
//initialized with NULL:
QVector<Node*> *dnv = new QVector<Node*>(allNodes->length(),NULL);
for (int i = 0; i<icons->length(); i++){
int f = icons->fs.at(i);
int t = icons->ts.at(i);
float v = icons->vs.at(i);
Connection* acon = new Connection(allNodes->at(f), allNodes->at(t),v);
Node* n1 = new Node(acon->fn);
if (dnv->at(f)==NULL) {
dnv->replace(f,n1);
}
dnv->at(f)->ncs << acon;
dnv->at(f)->sncs << acon;
acon = new Connection(allNodes->at(t), allNodes->at(f),v);
Node* n2 = new Node(acon->fn);
if (dnv->at(t)==NULL) {
dnv->replace(t,n2);
}
dnv->at(t)->ncs << acon;
dnv->at(t)->sncs << acon;
}
qDebug() << "before putting nodes in dn";
qDebug() << nodes.size();
for (int i = 0; i<nodes.size(); i++){
if (dnv->at(i+offset)!=NULL){
dn << *dnv->at(i+offset);
}
}
//qDebug() << "before sorting nodes";
for (int i = 0; i<dn.length(); i++){
//after this, sncs should be sorted by color, but contain the original indexing...
dn[i].indexCons();
dn[i].sortNCS();
}
delete dnv;
qDebug() << "done with creating " << dn.length() << " nodes from " << icons->length() << " indexed connections";
}
示例4: perform_grep
sqlqueryresultlist searchhandler::perform_grep(QString searchtxt, sqlqueryresultlist searchlist, bool exactmatch)
{
QVector<QString> strvec;
sqlqueryresultlist resultlist;
QFutureWatcher<sqlqueryresultlist> futureWatcher;
QProgressDialog dialog;
unsigned int n = searchlist.resultlist.size();
if (n == 0) return resultlist;
strvec.resize(n);
for (unsigned int i=0; i < n; i++)
{
strvec.replace(i, str2qt(searchlist.resultlist[i].filepath));
}
dialog.setAutoReset(false);
dialog.setLabelText(QString("Grep ").append(QString(tr("in progress"))).append(QString(" ...")));
dialog.setCancelButtonText(tr("Cancel"));
QObject::connect(&futureWatcher, SIGNAL(finished()), &dialog, SLOT(reset()));
QObject::connect(&dialog, SIGNAL(canceled()), &futureWatcher, SLOT(cancel()));
QObject::connect(&futureWatcher, SIGNAL(progressRangeChanged(int,int)), &dialog, SLOT(setRange(int,int)));
QObject::connect(&futureWatcher, SIGNAL(progressValueChanged(int)), &dialog, SLOT(setValue(int)));
m_grepExactMatch = exactmatch;
(*m_grepRegExp) = QRegExp(searchtxt.toAscii().data(), Qt::CaseInsensitive);
m_grepRegExp->setPatternSyntax(QRegExp::RegExp2);
futureWatcher.setFuture(QtConcurrent::mappedReduced(strvec, doGrep,
collateGrep, QtConcurrent::SequentialReduce));
dialog.exec();
futureWatcher.waitForFinished();
if (futureWatcher.isCanceled() == false)
resultlist = futureWatcher.result();
return resultlist;
}
示例5:
QVector<Vector3f> CVlib::divideByW(QVector<Vector3f> list)
{
for(int i = 0 ; i < list.count(); i++){
list.replace(i, list.at(i)/list.at(i)(2));
}
return list;
}
示例6: seedSequence
KNMusicNowPlaying::KNMusicNowPlaying(QObject *parent) :
KNMusicNowPlayingBase(parent),
m_backend(nullptr),
m_playingProxyModel(nullptr),
m_shadowPlayingModel(new KNMusicProxyModel(this)),
m_temporaryProxyPlaylist(new KNMusicProxyModel(this)),
m_temporaryPlaylist(new KNMusicTemporaryPlaylistModel(this)),
m_playingTab(nullptr),
m_loopState(NoRepeat),
m_playingIndex(QPersistentModelIndex()),
m_playingAnalysisItem(KNMusicAnalysisItem()),
m_manualPlayed(false)
{
//Set the temporary playlist to the proxy model.
m_temporaryProxyPlaylist->setSourceModel(m_temporaryPlaylist);
//Initial the random device and random generator.
QVector<int> seedData;
//Generate the random device.
std::random_device randomDevice;
//Get the seed array size.
const int seedCount=(int)std::mt19937::state_size;
//Resize the seed data.
seedData.resize(seedCount);
//Set the data to the seed data.
for(int i=0; i<seedCount; ++i)
{
//Replace the seed data.
seedData.replace(i, randomDevice());
}
//Transform list to seed sequence.
std::seed_seq seedSequence(std::begin(seedData), std::end(seedData));
//Initial the Mersenne twister seeds.
m_mersenneSeed=std::mt19937(seedSequence);
}
示例7: reset
/* -------------------------------------------------------------------------------------------
*
* ------------------------------------------------------------------------------------------- */
void Matrix::reset(const short value) {
Q_ASSERT(this->grid != 0x0);
for(int row = 0; row < this->rows; row++){
QVector<short> *r = this->grid->at(row);
for(int col =0; col < this->cols; col++){
r->replace(col,value);
}
}
}
示例8: ponerTabla
void WidgetAgregarStreamPeru::ponerTabla(int row, int col){
int pos, n,pos_r,var=0;
pos=row*12;
n=rowsp.size();
if(col==0){
for(int i=0; i<n;i++){
if(rowsp[i]==row){
pos_r=i;
var=var+1;
}}
if(var==0){
rowsp.append(row);
BDsperu.replace(pos,"1");
}else{
rowsp.remove(pos_r);
BDsperu.replace(pos,"0"); }
}}
示例9: getBytes
void FileBuffer::getBytes(long ofs, QVector<uchar>& b, int length)
{
if (ofs < offset || ((ofs + length) - 1) > offsetEnd)
{
readBuffer(ofs);
}
for (int i = 0; i < length; ++i)
{
b.replace(i, buf[(int)((ofs - offset) + i)]);
}
}
示例10: init
void QDesktopWidgetPrivate::init(QDesktopWidget *that)
{
int screenCount=0;
if (HAL::Get(0, HALData::EDisplayNumberOfScreens, screenCount) == KErrNone)
QDesktopWidgetPrivate::screenCount = screenCount;
else
QDesktopWidgetPrivate::screenCount = 0;
rects = new QVector<QRect>();
workrects = new QVector<QRect>();
rects->resize(QDesktopWidgetPrivate::screenCount);
workrects->resize(QDesktopWidgetPrivate::screenCount);
// ### TODO: Implement proper multi-display support
rects->resize(1);
rects->replace(0, that->rect());
workrects->resize(1);
workrects->replace(0, that->rect());
}
示例11: qRgb
const QVector<QRgb> ImageLoaderFreeImage::colorTable() const
{
QVector<QRgb> result;
const RGBQUAD* const palette = FreeImage_GetPalette(m_bitmap);
if (palette) {
const int count = FreeImage_GetColorsUsed(m_bitmap);
result.resize(count);
for (int i = 0; i < count; i++)
result.replace(i, qRgb(palette[i].rgbRed, palette[i].rgbGreen, palette[i].rgbBlue));
}
return result;
}
示例12: qRed
QVector<float> ImageProcessor::findOccurrences(QImage input, int offset) {
QVector<float> returnMe;
returnMe.fill(0,256);
float single = 1.0 / (input.width() * input.height());
for(int x=0;x<input.width();x++) {
for(int y=0;y<input.height();y++) {
int pixelIndex = qRed(input.pixel(x,y)) + offset;
pixelIndex = qMax(pixelIndex,0);
pixelIndex = qMin(pixelIndex,255);
float newVal = returnMe.value(pixelIndex)+single;
returnMe.replace(pixelIndex,newVal);
}
}
return returnMe;
}
示例13: addToRegChain
void EziDebugScanChain::addToRegChain(QString clock ,int chainNum , const QStringList& reglist)
{
QVector<QStringList> iregListVec = m_iregChainStructure.value(clock) ;
int i = 0 ;
qDebug() << "EziDebug Info: The insert chain number:" << chainNum ;
if(iregListVec.count())
{
for(i = 0 ; i < iregListVec.count() ; i++)
{
// 加入到 未完毕的链
if(i == chainNum)
{
QStringList ioriginRegList = iregListVec.at(i) ;
ioriginRegList << reglist ;
iregListVec.replace(i,ioriginRegList);
m_iregChainStructure.insert(clock,iregListVec);
break ;
}
}
// 新增链
if(i == iregListVec.count())
{
// 新增 链
if(chainNum != iregListVec.count())
{
qDebug() << "EziDebug Error: the reglist is insert chain number:" << chainNum <<" is not equal to total number:" << iregListVec.count() ;
}
iregListVec.insert(chainNum ,reglist);
m_iregChainStructure.insert(clock,iregListVec);
}
}
else
{
if(chainNum != 0)
{
qDebug() << "EziDebug Error: the reglist is insert chain number:" << chainNum <<" is not right" ;
}
iregListVec.insert(0,reglist);
m_iregChainStructure.insert(clock,iregListVec);
}
return ;
}
示例14: compressedFile
// Note: Callgrind sometimes gives different IDs for same file
// (when references to same source file come from different ELF objects)
TraceFile* CachegrindLoader::compressedFile(const QString& name)
{
if ((name[0] != '(') || !name[1].isDigit()) return _data->file(checkUnknown(name));
// compressed format using _fileVector
int p = name.indexOf(')');
if (p<2) {
error(QStringLiteral("Invalid compressed file ('%1')").arg(name));
return 0;
}
int index = name.midRef(1, p-1).toUInt();
TraceFile* f = 0;
p++;
while((name.length()>p) && name.at(p).isSpace()) p++;
if (name.length()>p) {
if (_fileVector.size() <= index) {
int newSize = index * 2;
#if TRACE_LOADER
qDebug() << " CachegrindLoader::fileVector enlarged to "
<< newSize;
#endif
_fileVector.resize(newSize);
}
QString realName = checkUnknown(name.mid(p));
f = (TraceFile*) _fileVector.at(index);
if (f && (f->name() != realName)) {
error(QStringLiteral("Redefinition of compressed file index %1 (was '%2') to %3")
.arg(index).arg(f->name()).arg(realName));
}
f = _data->file(realName);
_fileVector.replace(index, f);
}
else {
if ((_fileVector.size() <= index) ||
( (f=(TraceFile*)_fileVector.at(index)) == 0)) {
error(QStringLiteral("Undefined compressed file index %1").arg(index));
return 0;
}
}
return f;
}
示例15: compressedObject
TraceObject* CachegrindLoader::compressedObject(const QString& name)
{
if ((name[0] != '(') || !name[1].isDigit()) return _data->object(checkUnknown(name));
// compressed format using _objectVector
int p = name.indexOf(')');
if (p<2) {
error(QStringLiteral("Invalid compressed ELF object ('%1')").arg(name));
return 0;
}
int index = name.midRef(1, p-1).toInt();
TraceObject* o = 0;
p++;
while((name.length()>p) && name.at(p).isSpace()) p++;
if (name.length()>p) {
if (_objectVector.size() <= index) {
int newSize = index * 2;
#if TRACE_LOADER
qDebug() << " CachegrindLoader: objectVector enlarged to "
<< newSize;
#endif
_objectVector.resize(newSize);
}
QString realName = checkUnknown(name.mid(p));
o = (TraceObject*) _objectVector.at(index);
if (o && (o->name() != realName)) {
error(QStringLiteral("Redefinition of compressed ELF object index %1 (was '%2') to %3")
.arg(index).arg(o->name()).arg(realName));
}
o = _data->object(realName);
_objectVector.replace(index, o);
}
else {
if ((_objectVector.size() <= index) ||
( (o=(TraceObject*)_objectVector.at(index)) == 0)) {
error(QStringLiteral("Undefined compressed ELF object index %1").arg(index));
return 0;
}
}
return o;
}