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


C++ QVector::constData方法代码示例

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


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

示例1: insertLines

void QDocumentBuffer::insertLines(int after, const QVector<QDocumentLineHandle*>& l)
{
	int index = after + 1;
	int blockIndex = blockForLine(index);
	
	if ( blockIndex == -1 )
	{
		qWarning("cannot insert line at pos %i", index);
		return;
	}
	
	int n = l.count();
	Block *b = m_blocks.at(blockIndex);
	
	if ( (b->size() + 1) >= m_forkThresold )
	{
		// split block
		int bounds = b->start + m_optimalSize;
		
		Block *nb = new Block(bounds);
		nb->insert(bounds, b->lines.constData() + m_optimalSize, b->size() - m_optimalSize);
		nb->append(l.constData(), n);
		nb->end = bounds + nb->size();
		m_blocks.insert(blockIndex + 1, nb);
		
		b->lines.resize(m_optimalSize);
		b->end = bounds;
		
		blockIndex += 2;
	} else {
		b->insert(index, l.constData(), n);
	}
	
	// update block boundaries
	while ( blockIndex < m_blocks.count() )
	{
		b = m_blocks.at(blockIndex);
		b->start += n;
		b->end += n;
	}
}
开发者ID:dennisscully,项目名称:Cheezy,代码行数:41,代码来源:qdocumentbuffer.cpp

示例2: appendValue

bool OctreePacketData::appendValue(const QVector<float>& value) {
    uint16_t qVecSize = value.size();
    bool success = appendValue(qVecSize);
    if (success) {
        success = append((const unsigned char*)value.constData(), qVecSize * sizeof(float));
        if (success) {
            _bytesOfValues += qVecSize * sizeof(float);
            _totalBytesOfValues += qVecSize * sizeof(float);
        }
    }
    return success;
}
开发者ID:Giugiogia,项目名称:hifi,代码行数:12,代码来源:OctreePacketData.cpp

示例3: AMnDIndex

void AM3DAdditionAB::computeCachedValues() const
{
	AMnDIndex start = AMnDIndex();
	AMnDIndex end = AMnDIndex();

	if (dirtyIndices_.isEmpty()){

		start = AMnDIndex(rank(), AMnDIndex::DoInit);
		end = size()-1;
	}

	else {

		start = dirtyIndices_.first();
		end = dirtyIndices_.last();
		end[rank()-1] = size(rank()-1);
	}

	int totalSize = start.totalPointsTo(end);
	int flatStartIndex = start.flatIndexInArrayOfSize(size());
	QVector<double> data = QVector<double>(totalSize);
	sources_.at(0)->values(start, end, data.data());

	// Do the first data source separately to initialize the values.
	memcpy(cachedData_.data()+flatStartIndex, data.constData(), totalSize*sizeof(double));
	cachedData_ = data;

	// Iterate through the rest of the sources.
	for (int i = 1, count = sources_.size(); i < count; i++){

		sources_.at(i)->values(start, end, data.data());

		for (int j = 0; j < totalSize; j++)
			cachedData_[flatStartIndex+j] += data.at(j);
	}

	if (dirtyIndices_.isEmpty())
		cachedDataRange_ = AMUtility::rangeFinder(cachedData_);

	else{
		AMRange cachedRange = AMUtility::rangeFinder(cachedData_.mid(flatStartIndex, totalSize));

		if (cachedDataRange_.minimum() > cachedRange.minimum())
			cachedDataRange_.setMinimum(cachedRange.minimum());

		if (cachedDataRange_.maximum() < cachedRange.maximum())
			cachedDataRange_.setMaximum(cachedRange.maximum());
	}

	cacheUpdateRequired_ = false;
	dirtyIndices_.clear();
}
开发者ID:acquaman,项目名称:acquaman,代码行数:52,代码来源:AM3DAdditionAB.cpp

示例4: fromVariantMap

/*!
    Converts the variant map \a map to a QJsonObject.

    The keys in \a map will be used as the keys in the JSON object,
    and the QVariant values will be converted to JSON values.

    \sa fromVariantHash(), toVariantMap(), QJsonValue::fromVariant()
 */
QJsonObject QJsonObject::fromVariantMap(const QVariantMap &map)
{
    QJsonObject object;
    if (map.isEmpty())
        return object;

    object.detach2(1024);

    QVector<QJsonPrivate::offset> offsets;
    QJsonPrivate::offset currentOffset;
    currentOffset = sizeof(QJsonPrivate::Base);

    // the map is already sorted, so we can simply append one entry after the other and
    // write the offset table at the end
    for (QVariantMap::const_iterator it = map.constBegin(); it != map.constEnd(); ++it) {
        QString key = it.key();
        QJsonValue val = QJsonValue::fromVariant(it.value());

        bool latinOrIntValue;
        int valueSize = QJsonPrivate::Value::requiredStorage(val, &latinOrIntValue);

        bool latinKey = QJsonPrivate::useCompressed(key);
        int valueOffset = sizeof(QJsonPrivate::Entry) + QJsonPrivate::qStringSize(key, latinKey);
        int requiredSize = valueOffset + valueSize;

        if (!object.detach2(requiredSize + sizeof(QJsonPrivate::offset))) // offset for the new index entry
            return QJsonObject();

        QJsonPrivate::Entry *e = reinterpret_cast<QJsonPrivate::Entry *>(reinterpret_cast<char *>(object.o) + currentOffset);
        e->value.type = val.t;
        e->value.latinKey = latinKey;
        e->value.latinOrIntValue = latinOrIntValue;
        e->value.value = QJsonPrivate::Value::valueToStore(val, (char *)e - (char *)object.o + valueOffset);
        QJsonPrivate::copyString((char *)(e + 1), key, latinKey);
        if (valueSize)
            QJsonPrivate::Value::copyData(val, (char *)e + valueOffset, latinOrIntValue);

        offsets << currentOffset;
        currentOffset += requiredSize;
        object.o->size = currentOffset;
    }

    // write table
    object.o->tableOffset = currentOffset;
    if (!object.detach2(sizeof(QJsonPrivate::offset)*offsets.size()))
        return QJsonObject();
    memcpy(object.o->table(), offsets.constData(), offsets.size()*sizeof(uint));
    object.o->length = offsets.size();
    object.o->size = currentOffset + sizeof(QJsonPrivate::offset)*offsets.size();

    return object;
}
开发者ID:2gis,项目名称:2gisqt5android,代码行数:60,代码来源:qjsonobject.cpp

示例5: operator_intersect_data

void tst_QRegion::operator_intersect_data()
{
    QTest::addColumn<QRegion>("r1");
    QTest::addColumn<QRegion>("r2");
    QTest::addColumn<QRegion>("expected");

    QTest::newRow("empty 0") << QRegion() << QRegion() << QRegion();
    QTest::newRow("empty 1") << QRegion() << QRegion(QRect(10, 10, 10, 10))
                             << QRegion();
    QTest::newRow("empty 2") << QRegion(QRect(10, 10, 10, 10)) << QRegion()
                             << QRegion();

    QRegion dest;
    QVector<QRect> rects;
    rects << QRect(10, 10, 10, 10) << QRect(22, 10, 10, 10);
    dest.setRects(rects.constData(), rects.size());
    QTest::newRow("simple 1") << dest
                              << QRegion(22, 10, 10, 10)
                              << QRegion(22, 10, 10, 10);
    QTest::newRow("simple 2") << dest
                              << QRegion(10, 10, 10, 10)
                              << QRegion(10, 10, 10, 10);

    rects.clear();
    rects << QRect(10, 10, 10, 10) << QRect(10, 20, 15, 10);
    dest.setRects(rects.constData(), rects.size());
    QTest::newRow("merge 1") << dest
                             << QRegion(10, 10, 10, 20)
                             << QRegion(10, 10, 10, 20);

    rects.clear();
    rects << QRect(11, 11, 218, 117) << QRect(11, 128, 218, 27)
          << QRect(264, 128, 122, 27) << QRect(11, 155, 218, 43)
          << QRect(11, 198, 218, 27) << QRect(264, 198, 122, 27)
          << QRect(11, 225, 218, 221);
    dest.setRects(rects.constData(), rects.size());
    QTest::newRow("merge 2") << dest << QRegion(11, 11, 218, 458)
                             << QRegion(11, 11, 218, 435);

    rects.clear();
    rects << QRect(0, 0, 10, 10) << QRect(20, 0, 10, 10);
    dest.setRects(rects.constData(), rects.size());
    QTest::newRow("empty 3") << dest << QRegion(11, 0, 5, 5) << QRegion();

    QTest::newRow("extents check") << dest << QRegion(0, 0, 15, 15)
                                   << QRegion(0, 0, 10, 10);

    rects.clear();
    rects << QRect(10, 10, 10, 10) << QRect(10, 20, 10, 10)
          << QRect(30, 20, 10, 10) << QRect(10, 30, 10, 10);
    dest.setRects(rects.constData(), rects.size());
    rects.clear();
    rects << QRect(10, 10, 10, 10) << QRect(10, 20, 10, 10)
          << QRect(30, 20, 10, 10);
    QRegion expected;
    expected.setRects(rects.constData(), rects.size());
    QTest::newRow("dont merge") << dest << QRegion(0, 0, 100, 30)
                                << expected;
}
开发者ID:,项目名称:,代码行数:59,代码来源:

示例6: create

void Grid::create()
{
    // Allocate some storage to hold per-vertex data
    QVector<float> v;         // Vertices
    QVector<unsigned int> el; // Element indices

    // Generate the vertex data
    generateVertexData( v, el );

    // Create and populate the buffer objects
    m_positionBuffer.create();
    m_positionBuffer.setUsagePattern( QOpenGLBuffer::StaticDraw );
    m_positionBuffer.bind();
    m_positionBuffer.allocate( v.constData(), v.size() * sizeof( float ) );

#if 0
    m_indexBuffer.create();
    m_indexBuffer.setUsagePattern( QOpenGLBuffer::StaticDraw );
    m_indexBuffer.bind();
    m_indexBuffer.allocate( el.constData(), el.size() * sizeof( unsigned int ) );
#endif
    updateVertexArrayObject();
}
开发者ID:QtOpenGL,项目名称:opengl-demos,代码行数:23,代码来源:grid.cpp

示例7: beginPaint

void QXcbNativeBackingStore::beginPaint(const QRegion &region)
{
#if QT_CONFIG(xrender)
    if (m_translucentBackground) {
        const QVector<XRectangle> xrects = qt_region_to_xrectangles(region);
        const XRenderColor color = { 0, 0, 0, 0 };
        XRenderFillRectangles(display(), PictOpSrc,
                              qt_x11PictureHandle(m_pixmap), &color,
                              xrects.constData(), xrects.size());
    }
#else
    Q_UNUSED(region);
#endif
}
开发者ID:,项目名称:,代码行数:14,代码来源:

示例8: setReplyCallback

bool QDBusPendingCallPrivate::setReplyCallback(QObject *target, const char *member)
{
    receiver = target;
    metaTypes.clear();
    methodIdx = -1;
    if (!target)
        return true;;           // unsetting

    if (!member || !*member) {
        // would not be able to deliver a reply
        qWarning("QDBusPendingCall::setReplyCallback: error: cannot deliver a reply to %s::%s (%s)",
                 target ? target->metaObject()->className() : "(null)",
                 member ? member + 1 : "(null)",
                 target ? qPrintable(target->objectName()) : "no name");
        return false;
    }

    methodIdx = QDBusConnectionPrivate::findSlot(target, member + 1, metaTypes);
    if (methodIdx == -1) {
        QByteArray normalizedName = QMetaObject::normalizedSignature(member + 1);
        methodIdx = QDBusConnectionPrivate::findSlot(target, normalizedName, metaTypes);
    }
    if (methodIdx == -1) {
        // would not be able to deliver a reply
        qWarning("QDBusPendingCall::setReplyCallback: error: cannot deliver a reply to %s::%s (%s)",
                 target->metaObject()->className(),
                 member + 1, qPrintable(target->objectName()));
        return false;
    }

    // success
    // construct the expected signature
    int count = metaTypes.count() - 1;
    if (count == 1 && metaTypes.at(1) == QDBusMetaTypeId::message) {
        // wildcard slot, can receive anything, so don't set the signature
        return true;
    }

    if (metaTypes.at(count) == QDBusMetaTypeId::message)
        --count;

    if (count == 0) {
        setMetaTypes(count, 0);
    } else {
        QVector<int> types = QVector<int>::fromList(metaTypes);
        setMetaTypes(count, types.constData() + 1);
    }
    return true;
}
开发者ID:fluxer,项目名称:katie,代码行数:49,代码来源:qdbuspendingcall.cpp

示例9: renderMesh

void MonoFaceShader::renderMesh(QColor meshColor,
                                QVector<QVector3D>& vertices,
                                QVector<QVector3D>& normals)
{
    if (vertices.size() != normals.size())
        throw runtime_error("vertex and normal array not same size MonoFaceShader::renderMesh");

    _program->setUniformValue(_uniforms["sourceColor"],
                  meshColor.redF(),
                  meshColor.greenF(),
                  meshColor.blueF(),
                  1.0f);

    GLuint normalAttr = _attributes["normal"];
    GLuint vertexAttr = _attributes["vertex"];

    _program->setAttributeArray(vertexAttr, vertices.constData());
    _program->setAttributeArray(normalAttr, normals.constData());
    _program->enableAttributeArray(normalAttr);
    _program->enableAttributeArray(vertexAttr);
    glDrawArrays(GL_TRIANGLES, 0, vertices.size());
    _program->disableAttributeArray(normalAttr);
    _program->disableAttributeArray(vertexAttr);
}
开发者ID:OpenScadHullModelling,项目名称:ShipCAD,代码行数:24,代码来源:shader.cpp

示例10: renderPoints

void LineShader::renderPoints(QVector<QVector3D>& points, QColor color)
{
    _program->setUniformValue(_uniforms["sourceColor"],
                  color.redF(),
                  color.greenF(),
                  color.blueF(),
                  1.0f);

    GLuint posAttr = _attributes["posAttr"];

    _program->setAttributeArray(posAttr, points.constData());
    _program->enableAttributeArray(posAttr);
    glDrawArrays(GL_POINTS, 0, points.size());
    _program->disableAttributeArray(posAttr);
}
开发者ID:OpenScadHullModelling,项目名称:ShipCAD,代码行数:15,代码来源:shader.cpp

示例11: bindTextureToBuffer

void XCompositeEglClientBufferIntegration::bindTextureToBuffer(struct ::wl_resource *buffer)
{
    XCompositeBuffer *compositorBuffer = XCompositeBuffer::fromResource(buffer);
    Pixmap pixmap = XCompositeNameWindowPixmap(mDisplay, compositorBuffer->window());

    QVector<EGLint> eglConfigSpec = eglbuildSpec();

    EGLint matching = 0;
    EGLConfig config;
    bool matched = eglChooseConfig(mEglDisplay,eglConfigSpec.constData(),&config,1,&matching);
    if (!matched || !matching) {
        qWarning("Could not retrieve a suitable EGL config");
        return;
    }

    QVector<EGLint> attribList;

    attribList.append(EGL_TEXTURE_FORMAT);
    attribList.append(EGL_TEXTURE_RGBA);
    attribList.append(EGL_TEXTURE_TARGET);
    attribList.append(EGL_TEXTURE_2D);
    attribList.append(EGL_NONE);

    EGLSurface surface = eglCreatePixmapSurface(mEglDisplay,config,pixmap,attribList.constData());
    if (surface == EGL_NO_SURFACE) {
        qDebug() << "Failed to create eglsurface" << pixmap << compositorBuffer->window();
    }

    compositorBuffer->setInvertedY(true);

    if (!eglBindTexImage(mEglDisplay,surface,EGL_BACK_BUFFER)) {
        qDebug() << "Failed to bind";
    }

    //    eglDestroySurface(mEglDisplay,surface);
}
开发者ID:RobinWuDev,项目名称:Qt,代码行数:36,代码来源:xcompositeeglintegration.cpp

示例12:

MetaType * MetaType::find( int id )
{
  int n = gMetaTypes.count();
  MetaType * const * d = gMetaTypes.constData();

  int i;
  for(i = 0; i < n; ++i)
  {
      if((*d)->mId == id)
        return *d;
      ++d;
  }

  return 0;
}
开发者ID:acamari,项目名称:supercollider,代码行数:15,代码来源:metatype.cpp

示例13: renderLines

void LineShader::renderLines(QVector<QVector3D>& vertices, QColor lineColor)
{
    _program->setUniformValue(_uniforms["sourceColor"],
                  lineColor.redF(),
                  lineColor.greenF(),
                  lineColor.blueF(),
                  1.0f);

    GLuint posAttr = _attributes["posAttr"];

    _program->setAttributeArray(posAttr, vertices.constData());
    _program->enableAttributeArray(posAttr);
    glDrawArrays(GL_LINES, 0, vertices.size());
    _program->disableAttributeArray(posAttr);
}
开发者ID:OpenScadHullModelling,项目名称:ShipCAD,代码行数:15,代码来源:shader.cpp

示例14: rectCount_data

void tst_QRegion::rectCount_data()
{
    QTest::addColumn<QRegion>("region");
    QTest::addColumn<int>("expected");

    QTest::newRow("empty") << QRegion() << 0;
    QTest::newRow("rect") << QRegion(10, 10, 10, 10) << 1;

    QRegion dest;
    QVector<QRect> rects;
    rects << QRect(10, 10, 10, 10) << QRect(22, 10, 10, 10);
    dest.setRects(rects.constData(), rects.size());

    QTest::newRow("2 rects") << dest << rects.size();
}
开发者ID:,项目名称:,代码行数:15,代码来源:

示例15: put

void IdTreeDB::put(quint64 docId, const QVector<quint64> subDocIds)
{
    Q_ASSERT(!subDocIds.isEmpty());
    Q_ASSERT(!subDocIds.contains(0));

    MDB_val key;
    key.mv_size = sizeof(quint64);
    key.mv_data = static_cast<void*>(&docId);

    MDB_val val;
    val.mv_size = subDocIds.size() * sizeof(quint64);
    val.mv_data = static_cast<void*>(const_cast<quint64*>(subDocIds.constData()));

    int rc = mdb_put(m_txn, m_dbi, &key, &val, 0);
    Q_ASSERT_X(rc == 0, "IdTreeDB::put", mdb_strerror(rc));
}
开发者ID:KDE,项目名称:baloo,代码行数:16,代码来源:idtreedb.cpp


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