本文整理汇总了C++中QArray类的典型用法代码示例。如果您正苦于以下问题:C++ QArray类的具体用法?C++ QArray怎么用?C++ QArray使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了QArray类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: int
string ClsFEGroupPlot::wSpacePlotSelected2Range(QArray<int> &qarraySelected){
string strRange;
if(dynamic_cast<ClsTopologySparse*>(ClsFESystemManager::Instance()->getFEGroup( strGroupID )->getTopology())){
ClsTopologySparse *clsTopologySparse = dynamic_cast<ClsTopologySparse*>(ClsFESystemManager::Instance()->getFEGroup( strGroupID )->getTopology());
iGroupWidth = clsTopologySparse->nrCellsHorizontal();
iGroupHeight = clsTopologySparse->nrCellsVertical();
for(unsigned int ii = 0; ii< qarraySelected.size(); ii++){
int iy = int(qarraySelected[ii] / iGroupWidth) + 1;
int ix = qarraySelected[ii] - int(qarraySelected[ii] / iGroupWidth) * iGroupWidth + 1;
if(clsTopologySparse->isValidCell(ix, iy)){
// cout << "clsTopologySparse->pos2index(ix, iy): " << clsTopologySparse->pos2index(ix, iy) << endl;
// cout << __FILE__ << ": ix, iy: " << ix << ", " << iy << endl;
strRange = iqrUtils::int2string(clsTopologySparse->pos2index(ix, iy)) + ";" + strRange ;
}
}
} else {
for(unsigned int ii = 0; ii< qarraySelected.size(); ii++){
strRange = iqrUtils::int2string(qarraySelected[ii]) + ";" + strRange ;
}
}
return strRange;
}
示例2: setIndexes
/*!
Replaces the elements of this index buffer, starting at \a index,
with the contents of \a values. All other elements keep their
current values.
If the index buffer has been uploaded to the GL server, then this
function must be called with a current GL context that is compatible
with the uploaded buffer.
The index buffer must have been originally created with the
int element type.
OpenGL/ES systems usually do not support 32-bit index values unless
they have a special extension for that purpose. On systems without
32-bit index values, this function will need to convert all values
to 16-bit which may incur a performance penalty and lose information.
\sa setIndexes()
*/
void QGLIndexBuffer::replaceIndexes(int index, const QArray<uint>& values)
{
Q_D(QGLIndexBuffer);
Q_ASSERT_X(d->elementType == GL_UNSIGNED_INT || !d->hasIntBuffers,
"QGLIndexBuffer::replaceIndexes()",
"buffer created with ushort element type, replacing with int");
if (d->elementType != GL_UNSIGNED_INT && d->hasIntBuffers)
return;
if (d->buffer.isCreated()) {
if (d->hasIntBuffers) {
d->buffer.bind();
d->buffer.write(index * sizeof(int),
values.constData(), values.size() * sizeof(int));
d->buffer.release();
} else {
QArray<ushort> svalues = qt_qarray_uint_to_ushort(values);
d->buffer.bind();
d->buffer.write(index * sizeof(ushort),
svalues.constData(),
svalues.size() * sizeof(ushort));
d->buffer.release();
}
} else if (d->elementType == GL_UNSIGNED_INT) {
d->indexesInt.replace(index, values.constData(), values.size());
d->indexCount = d->indexesInt.size();
} else {
QArray<ushort> svalues = qt_qarray_uint_to_ushort(values);
d->indexesShort.replace(index, svalues.constData(), svalues.size());
d->indexCount = d->indexesShort.size();
}
}
示例3: contactCompare
bool AbView::contactCompare( const Opie::OPimContact &cnt, int category )
{
// odebug << "bool AbView::contactCompare( const Opie::OPimContact &cnt, "
// << category << " )" << oendl;
bool returnMe;
QArray<int> cats;
cats = cnt.categories();
// odebug << "Number of categories: " << cats.count() << oendl;
returnMe = false;
if ( cats.count() == 0 && category == -1 )
// Contacts with no category will just shown on "All" and "Unfiled"
returnMe = true;
else {
int i;
for ( i = 0; i < int(cats.count()); i++ ) {
//odebug << "Comparing " << cats[i] << " with " << category << oendl;
if ( cats[i] == category ) {
returnMe = true;
break;
}
}
}
// odebug << "Return: " << returnMe << oendl;
return returnMe;
}
示例4: translate
/*!
Returns a copy of this array of QVector2D values, translated
by the components of \a value.
\sa translate()
*/
QArray<QVector2D> QVector2DArray::translated(const QVector2D& value) const
{
QArray<QVector2D> result;
int size = count();
QVector2D *dst = result.extend(size);
const QVector2D *src = constData();
for (int index = 0; index < size; ++index)
*dst++ = *src++ + value;
return result;
}
示例5: scale
/*!
Returns a copy of this array of QVector3D values, multiplied
by the \a scale.
\sa scale()
*/
QVector3DArray QVector3DArray::scaled(qreal scale) const
{
QArray<QVector3D> result;
int size = count();
const QVector3D *src = constData();
QVector3D *dst = result.extend(size);
for (int index = 0; index < size; ++index)
*dst++ = *src++ * scale;
return result;
}
示例6: main
int main()
{
std::cout << "version=" << QT_VERSION_STR << std::endl;
QArray<int> a = fib( 6 ); // get 6 first fibonaccis
if(4==a.find(5))
return 0;
return 1;
}
示例7: transform
/*!
Returns a copy of this array of QVector2D values,
transformed by \a matrix.
\sa transform()
*/
QArray<QVector2D> QVector2DArray::transformed(const QMatrix4x4& matrix) const
{
QArray<QVector2D> result;
int size = count();
const QVector2D *src = constData();
QVector2D *dst = result.extend(size);
for (int index = 0; index < size; ++index)
*dst++ = (matrix * QVector3D(*src++, 0.0f)).toVector2D();
return result;
}
示例8: labels
/*! Returns a list of all labels associated with the \a catids */
QStringList CategoryGroup::labels(const QArray<int> &catids ) const
{
QStringList labels;
if ( catids.count() == 0 )
return labels;
for ( QMap<int, QString>::ConstIterator it = mIdLabelMap.begin();
it != mIdLabelMap.end(); ++it )
if ( catids.find( it.key() ) != -1 )
labels += *it;
return labels;
}
示例9: rawRepeats
OEvent::ValueList ODateBookAccessBackend_SQL::directRawRepeats()
{
QArray<int> rawRepUids = rawRepeats();
OEvent::ValueList list;
for (uint i = 0; i < rawRepUids.count(); ++i ){
list.append( find( rawRepUids[i] ) );
}
return list;
}
示例10: scale
/*!
Returns a copy of this array of QVector2D values, multiplied
by the \a scale.
\sa scale()
*/
QVector2DArray QVector2DArray::scaled(qreal scale) const
{
const qreal identity = 1.0;
if (qFuzzyCompare(scale, identity))
return *this;
QArray<QVector2D> result;
int size = count();
const QVector2D *src = constData();
QVector2D *dst = result.extend(size);
for (int index = 0; index < size; ++index)
*dst++ = *src++ * scale;
return result;
}
示例11: uid
// Exporting Event data to map. Using the same
// encoding as ODateBookAccessBackend_xml does..
// Thus, we could remove the stuff there and use this
// for it and for all other places..
// Encoding should happen at one place, only ! (eilers)
QMap<int, QString> OEvent::toMap()const {
QMap<int, QString> retMap;
retMap.insert( OEvent::FUid, QString::number( uid() ) );
retMap.insert( OEvent::FCategories, Qtopia::escapeString( Qtopia::Record::idsToString( categories() ) ));
retMap.insert( OEvent::FDescription, Qtopia::escapeString( description() ) );
retMap.insert( OEvent::FLocation, Qtopia::escapeString( location() ) );
retMap.insert( OEvent::FType, isAllDay() ? "AllDay" : "" );
OPimAlarm alarm = notifiers().alarms()[0];
retMap.insert( OEvent::FAlarm, QString::number( alarm.dateTime().secsTo( startDateTime() ) / 60 ) );
retMap.insert( OEvent::FSound, (alarm.sound() == OPimAlarm::Loud) ? "loud" : "silent" );
OTimeZone zone( timeZone().isEmpty() ? OTimeZone::current() : timeZone() );
retMap.insert( OEvent::FStart, QString::number( zone.fromUTCDateTime( zone.toDateTime( startDateTime(), OTimeZone::utc() ) ) ) );
retMap.insert( OEvent::FEnd, QString::number( zone.fromUTCDateTime( zone.toDateTime( endDateTime(), OTimeZone::utc() ) ) ) );
retMap.insert( OEvent::FNote, Qtopia::escapeString( note() ) );
retMap.insert( OEvent::FTimeZone, timeZone().isEmpty() ? QString( "None" ) : timeZone() );
if( parent() )
retMap.insert( OEvent::FRecParent, QString::number( parent() ) );
if( children().count() ){
QArray<int> childr = children();
QString buf;
for ( uint i = 0; i < childr.count(); i++ ) {
if ( i != 0 ) buf += " ";
buf += QString::number( childr[i] );
}
retMap.insert( OEvent::FRecChildren, buf );
}
// Add recurrence stuff
if( hasRecurrence() ){
ORecur recur = recurrence();
QMap<int, QString> recFields = recur.toMap();
retMap.insert( OEvent::FRType, recFields[ORecur::RType] );
retMap.insert( OEvent::FRWeekdays, recFields[ORecur::RWeekdays] );
retMap.insert( OEvent::FRPosition, recFields[ORecur::RPosition] );
retMap.insert( OEvent::FRFreq, recFields[ORecur::RFreq] );
retMap.insert( OEvent::FRHasEndDate, recFields[ORecur::RHasEndDate] );
retMap.insert( OEvent::FREndDate, recFields[ORecur::EndDate] );
retMap.insert( OEvent::FRCreated, recFields[ORecur::Created] );
retMap.insert( OEvent::FRExceptions, recFields[ORecur::Exceptions] );
} else {
ORecur recur = recurrence();
QMap<int, QString> recFields = recur.toMap();
retMap.insert( OEvent::FRType, recFields[ORecur::RType] );
}
return retMap;
}
示例12: replaceIndexes
/*!
Sets the index \a values in this index buffer, replacing the
entire current contents.
If the index buffer has been uploaded to the GL server, then this
function must be called with a current GL context that is compatible
with the uploaded buffer.
\sa replaceIndexes()
*/
void QGLIndexBuffer::setIndexes(const QArray<ushort>& values)
{
Q_D(QGLIndexBuffer);
if (d->buffer.isCreated()) {
d->buffer.bind();
d->buffer.allocate(values.constData(), values.size() * sizeof(ushort));
d->buffer.release();
// The element type may have changed from int to ushort.
d->elementType = GL_UNSIGNED_SHORT;
} else {
d->indexesShort = values;
d->elementType = GL_UNSIGNED_SHORT;
d->indexesInt = QArray<uint>();
}
d->indexCount = values.size();
}
示例13: id
/*!
Returns all ids associated with the application CategoryGroup \a app
and the passed in \a labels in that group.
*/
QArray<int> Categories::ids( const QString &app, const QStringList &labels) const
{
QArray<int> results;
QStringList::ConstIterator it;
int i;
for ( i=0, it=labels.begin(); it!=labels.end(); i++, ++it ) {
int value = id( app, *it );
if ( value != 0 ) {
int tmp = results.size();
results.resize( tmp + 1 );
results[ tmp ] = value;
}
}
return results;
}
示例14: processFloatList
/*!
\internal
Processes a list of floating point numbers. If the list contains only 1
element, a QVariant<float> is returned. If the list containst 2, 3 or 4
elements, they are converted into a QVariant containing a QVector2D,
QVector3D, or QVector4D respectively.
If the list containst more elements than that, they are returned as a
QArray<float>.
*/
QVariant QGLColladaFxEffectFactory::processFloatList( QXmlStreamReader& xml )
{
QArray<float> floats;
QString elementString = xml.readElementText();
QStringList list = elementString.split( QRegExp( "\\s+" ), QString::SkipEmptyParts );
bool ok;
float f;
foreach( QString string, list )
{
f = string.toFloat( &ok );
if( ok )
floats.append(string.toFloat());
else
{
qWarning() << "Warning: malformed float ( line" << xml.lineNumber() << ")";
}
}
示例15: qt_qarray_uint_to_ushort
static QArray<ushort> qt_qarray_uint_to_ushort(const QArray<uint> &array)
{
QArray<ushort> result;
const uint *values = array.constData();
int size = array.size();
bool largeValue = false;
result.reserve(size);
while (size-- > 0) {
uint value = *values++;
if (ushort(value) != value)
largeValue = true;
result.append(ushort(value));
}
if (largeValue)
qWarning("QGLIndexBuffer::setIndexes: large 32-bit value provided to a 16-bit only buffer");
return result;
}