本文整理汇总了C++中QVariantList::size方法的典型用法代码示例。如果您正苦于以下问题:C++ QVariantList::size方法的具体用法?C++ QVariantList::size怎么用?C++ QVariantList::size使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QVariantList
的用法示例。
在下文中一共展示了QVariantList::size方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: handleFinished
void QgsAmsLegendFetcher::handleFinished()
{
// Parse result
QJsonParseError err;
QJsonDocument doc = QJsonDocument::fromJson( mQueryReply, &err );
if ( doc.isNull() )
{
emit error( QStringLiteral( "Parsing error:" ).arg( err.errorString() ) );
}
QVariantMap queryResults = doc.object().toVariantMap();
QgsDataSourceUri dataSource( mProvider->dataSourceUri() );
QVector< QPair<QString, QImage> > legendEntries;
foreach ( const QVariant &result, queryResults["layers"].toList() )
{
QVariantMap queryResultMap = result.toMap();
QString layerId = queryResultMap[QStringLiteral( "layerId" )].toString();
if ( layerId != dataSource.param( QStringLiteral( "layer" ) ) && !mProvider->subLayers().contains( layerId ) )
{
continue;
}
QVariantList legendSymbols = queryResultMap[QStringLiteral( "legend" )].toList();
foreach ( const QVariant &legendEntry, legendSymbols )
{
QVariantMap legendEntryMap = legendEntry.toMap();
QString label = legendEntryMap[QStringLiteral( "label" )].toString();
if ( label.isEmpty() && legendSymbols.size() == 1 )
label = queryResultMap[QStringLiteral( "layerName" )].toString();
QByteArray imageData = QByteArray::fromBase64( legendEntryMap[QStringLiteral( "imageData" )].toByteArray() );
legendEntries.append( qMakePair( label, QImage::fromData( imageData ) ) );
}
}
示例2: currentPKValues
#include "tcomboboxmodelrecord.h"
TComboBoxModelRecord::TComboBoxModelRecord(QWidget *parent) :
QComboBox(parent)
{
currentModelColumn=0;
editable_=false;
connect( this,SIGNAL(currentIndexChanged(int)),SLOT(currentIndexChangedSlot(int)) );
}
///*! Devuelve el valor de la llave primaria del elemento seleccionado en el ComboBox
//\return Valor de la llave primaria.
//*/
QVariantList TComboBoxModelRecord::currentPKValues()
{
if ( count() == 0 )
return QVariantList();
ModelBase* m=(ModelBase*)originalModel;
QVariantList values;
if ( currentIndex() < 0 )
return QVariantList();
if ( currentIndex() == 0 && editable_ )
return QVariantList();
RecordBase *record = m->getRecord( editable_ ? lstFiltrados.at(currentIndex()) : currentIndex() );
foreach ( QString pk,
record->property(QString(m->getTableName()+"PKAttributesList").toLocal8Bit()).toStringList() )
values.append( record->property( pk.toLocal8Bit() ) );
return values;
}
///*! Selecciona el elemento en el ComboBox cuyo registro (Record) tenga la llave primaria \a id
//\param id Valor de la llave primaria a seleccionar.
//*/
void TComboBoxModelRecord::setCurrentPKValues(QVariantList lst)
{
if ( count() == 0 )
return;
ModelBase* m=(ModelBase*)model();
if ( m->getRecord(0)->property(QString(m->getTableName()+"PKAttributesList").toLocal8Bit()).toStringList().size()!=
lst.size())
return;
for ( int f=0; f<m->modelSize(); f++ )
{
RecordBase *record=m->getRecord(f);
bool error=false;
QStringList lstpk=record->property(QString(m->getTableName()+"PKAttributesList").toLocal8Bit()).toStringList();
for ( int c=0; c<lstpk.size(); c++)
{
QString pk=lstpk.at(c);
if ( record->property(pk.toLocal8Bit()) != lst.at(c))
{
error=true;
break;
}
}
if ( error )
continue;
setCurrentIndex(f);
break;
}
}
示例3: thumbnail
QUrl Media::thumbnail() const
{
if (m_thumbnail.isEmpty())
{
//photo
QVariantMap& media = m_message->media();
QVariantMap sz;
if (m_message->mediaType() == tgl_message_media_photo)
{
QVariantList sizes = media["sizes"].toList();
for (int i = 0; i < sizes.size(); i++)
{
sz = sizes[i].toMap();
if (sz["type"].toString() == "s")
break;
}
}
else
{
sz = media["thumb"].toMap();
}
tgl_photo_size photoSize;
photoSize.w = sz["width"].toInt();
photoSize.w = sz["height"].toInt();
photoSize.size = sz["size"].toInt();
photoSize.loc.volume = sz["volume"].toLongLong();
photoSize.loc.dc = sz["dc"].toInt();
photoSize.loc.local_id = sz["local_id"].toInt();
photoSize.loc.secret = sz["secret"].toLongLong();
tgl_do_load_photo_size(gTLS, &photoSize, _loadThumbnailCallback, (void*)this);
}
return m_thumbnail;
}
示例4: updateHubCategory
bool HubAccount::updateHubCategory(qint64 categoryId, qint64 parentCategoryId, QString name)
{
qint64 retVal = 0;
qDebug() << "update hub category: " << categoryId << " - " << parentCategoryId << " - " << name;
QVariantList categories = this->categories();
for(int index = 0; index < categories.size(); index++) {
QVariant category = categories.at(index);
QVariantMap categoryMap = category.toMap();
qint64 cacheCategoryId = categoryMap["categoryId"].toLongLong();
if (categoryId == cacheCategoryId) {
categoryMap["name"] = name;
categoryMap["parentCategoryId"] = parentCategoryId;
retVal = _udsUtil->updateCategory(_accountId, categoryId, name, parentCategoryId);
if (retVal <= 0) {
qDebug() << "HubAccount::updateHubCategory: updateCategory failed for category: " << name << ", account: "<< _accountId << ", retVal: "<< retVal << "\n";
} else {
_hubCache->setCategories(categories);
}
break;
}
}
return (retVal > 0);
}
示例5: fromQVariantList
bool QChemJobInfo::fromQVariantList(QVariantList const& list)
{
bool ok = (list.size() == 8) &&
list[0].canConvert<QString>() &&
list[1].canConvert<QString>() &&
list[2].canConvert<QString>() &&
list[3].canConvert<QString>() &&
list[4].canConvert<QString>() &&
list[5].canConvert<int>() &&
list[5].canConvert<int>() &&
list[7].canConvert<bool>();
if (ok) {
m_data.insert(BaseName, list[0].toString());
m_data.insert(ServerName, list[1].toString());
m_data.insert(LocalWorkingDirectory, list[2].toString());
m_data.insert(RemoteWorkingDirectory,list[3].toString());
m_data.insert(InputString, list[4].toString());
m_charge = list[5].toInt();
m_multiplicity = list[6].toInt();
m_localFilesExist = list[7].toBool();
}
return ok;
}
示例6: writeDesign
void writeDesign(QXmlStreamWriter &stream, const QVariantList &v)
{
stream.writeStartElement("design");
stream.writeAttribute("name", v[1].toString());
for (int i = 2; i < v.size(); i++)
{
QVariant v2 = v[i];
if (v2.type() == QVariant::List)
{
QVariantList l2 = v2.toList();
if (l2.size() > 0)
{
if (l2.first() == "cellRef")
{
writeCellRef(stream, l2);
}
else
{
qWarning("Unexpected tag '%s' in 'design' tag", qPrintable(l2.first().toString()));
}
}
}
}
stream.writeEndElement();
}
示例7: writeNetlistInterface
void writeNetlistInterface(QXmlStreamWriter &stream, const QVariantList &v)
{
stream.writeStartElement("interface");
for (int i = 1; i < v.size(); i++)
{
QVariant v2 = v[i];
if (v2.type() == QVariant::List)
{
QVariantList l2 = v2.toList();
if (l2.size() > 0)
{
QString tag = l2.first().toString();
if (tag == "port")
{
writePort(stream, l2);
}
else
{
qWarning("Unexpected tag '%s' in 'interface' tag", qPrintable(tag));
}
}
}
}
stream.writeEndElement();
}
示例8: get_training_dimensions
// Learning algorithm dataset integeration
void Dataset::get_training_dimensions(unsigned int *num_data, unsigned int *num_input, unsigned int *num_output)
{
*num_data = vdata.size();
*num_input = schema.size()-1;
*num_output = 1;
// Leave one out
if (leave_item != DONT_LEAVE_ANY)
(*num_data)--;
// Filter Meta Columns
for(int i=0; i<schema.size(); i++)
{
if (schema[i].value("Type").toInt() == COL_TYPE_META)
{
// cerr << "Removing column " << schema[i].value("Name").toString().toStdString() << endl;
(*num_input)--;
}
if (schema[i].value("Type").toInt() == COL_TYPE_CAT)
{
QVariantList values = schema[i].value("Values").toList();
// cerr << "Feeding " << schema[i].value("Name").toString().toStdString() << " - " << values.size() << " combinations." << endl;
(*num_input) += values.size() - 1;
}
}
}
示例9: get_scale_flags
void Dataset::get_scale_flags(int should_scale[])
{
unsigned input_index = 0;
for(int i=0; i<schema.size() - 1; i++)
{
switch(schema[i].value("Type").toInt())
{
case COL_TYPE_META:
continue;
case COL_TYPE_CAT:
{
QVariantList values = schema[i].value("Values").toList();
for(int j=0; j<values.size(); j++)
{
should_scale[input_index] = 0;
input_index++;
}
break;
}
case COL_TYPE_NUM:
should_scale[input_index] = 1;
input_index++;
break;
default:
qFatal("Unhandled variable type");
}
}
}
示例10: suggestionsObtained
void OpenSearchEngine::suggestionsObtained()
{
const QByteArray response = m_suggestionsReply->readAll();
m_suggestionsReply->close();
m_suggestionsReply->deleteLater();
m_suggestionsReply = 0;
QJsonParseError err;
QJsonDocument json = QJsonDocument::fromJson(response, &err);
const QVariant res = json.toVariant();
if (err.error != QJsonParseError::NoError || res.type() != QVariant::List)
return;
const QVariantList list = res.toList();
if (list.size() < 2)
return;
QStringList out;
foreach (const QVariant &v, list.at(1).toList())
out.append(v.toString());
emit suggestions(out);
}
示例11: getGroups
void MainWindow::getGroups()
{
qDebug() << " GET GROUPS FROM QML ";
QUrl current("https://api.vk.com/method/groups.get");
QUrlQuery query;
query.addQueryItem("v","5.2");
query.addQueryItem("access_token",Token);
query.addQueryItem("user_id","138685584");
query.addQueryItem("extended","1");
query.addQueryItem("count","1000");
query.addQueryItem("fields","members_count");
current.setQuery(query);
QByteArray answer = GET(current);
QVariantList List = JSON::parse(answer).toMap().value("response").toMap().value("items").toList(); // parse to list of objects Audio
/*GET Audio
QString du;
for (int i=0; i<List.size(); i++)
{
QVariantMap current = List[i].toMap();
du = current.value("url").toString();
qDebug() << current.value("url").toString();
qDebug() << current.value("id").toString();
qDebug() << current.value("title").toString();
}
*/
QQmlContext* context = rootContext();
groupModel = new GroupModel();
for (int i=0; i<List.size(); i++)
{
QVariantMap current = List[i].toMap();
groupModel->addGroup(Group(current.value("name").toString(),current.value("type").toString(),current.value("photo_50").toString(),current.value("members_count").toString(),current.value("id").toString()));
/*QVariantList attachments = current.value("attachments").toList();
for (int k=0; k<attachments.size(); k++)
{
QVariantMap cur = attachments[k].toMap();
if (cur.value("type").toString() == "audio")
{
qDebug() << "Audio";
qDebug() << cur.value("audio").toMap().value("url").toString();
links.append(cur.value("audio").toMap().value("url").toString());
}
}*/
}
context->setContextProperty("groupModel", groupModel);
//if success loaded data
if (1){
wallObj = rootObject();
QMetaObject::invokeMethod((QObject*)wallObj, "showGroupList");
}
}
示例12: parse
bool GetLocationsReply::parse(const QByteArray& data)
{
JsonDataAccess jsonObject;
QVariant node = jsonObject.loadFromBuffer(data);
if (jsonObject.hasError()) {
qWarning() << "error converting JSON data: " << jsonObject.error().errorMessage();
} else {
qDebug() << "before parse: " << QString(data);
QVariantMap map = node.value<QVariantMap>();
if (map["status"].toString() == "OK") {
m_status = true;
QVariantList friendList = map["friends"].value<QVariantList>();
for (int i = 0; i < friendList.size(); i++) {
QString friendStr = friendList[i].toString();
QStringList fields = friendStr.split(",");
// if incorrect number of fields, stop parsing
if (fields.size() != 4) return false;
QString ppId = fields.at(0);
double x = fields.at(1).toDouble();
double y = fields.at(2).toDouble();
int visibility = fields.at(3).toInt();
m_friends.append(User(ppId, x, y, visibility));
}
return true;
}
}
return false;
}
示例13: dataSource
QgsAmsProvider::QgsAmsProvider( const QString &uri, const ProviderOptions &options )
: QgsRasterDataProvider( uri, options )
{
mLegendFetcher = new QgsAmsLegendFetcher( this );
QgsDataSourceUri dataSource( dataSourceUri() );
const QString authcfg = dataSource.authConfigId();
mServiceInfo = QgsArcGisRestUtils::getServiceInfo( dataSource.param( QStringLiteral( "url" ) ), authcfg, mErrorTitle, mError );
mLayerInfo = QgsArcGisRestUtils::getLayerInfo( dataSource.param( QStringLiteral( "url" ) ) + "/" + dataSource.param( QStringLiteral( "layer" ) ), authcfg, mErrorTitle, mError );
const QVariantMap extentData = mLayerInfo.value( QStringLiteral( "extent" ) ).toMap();
mExtent.setXMinimum( extentData[QStringLiteral( "xmin" )].toDouble() );
mExtent.setYMinimum( extentData[QStringLiteral( "ymin" )].toDouble() );
mExtent.setXMaximum( extentData[QStringLiteral( "xmax" )].toDouble() );
mExtent.setYMaximum( extentData[QStringLiteral( "ymax" )].toDouble() );
mCrs = QgsArcGisRestUtils::parseSpatialReference( extentData[QStringLiteral( "spatialReference" )].toMap() );
if ( !mCrs.isValid() )
{
appendError( QgsErrorMessage( tr( "Could not parse spatial reference" ), QStringLiteral( "AMSProvider" ) ) );
return;
}
const QVariantList subLayersList = mLayerInfo.value( QStringLiteral( "subLayers" ) ).toList();
mSubLayers.reserve( subLayersList.size() );
for ( const QVariant &sublayer : subLayersList )
{
mSubLayers.append( sublayer.toMap()[QStringLiteral( "id" )].toString() );
mSubLayerVisibilities.append( true );
}
mTimestamp = QDateTime::currentDateTime();
mValid = true;
}
示例14: call
QVariant QuickInterpreter::call(QObject *ctx, const QString &func, const QVariantList &args)
{
QSList l;
for (int i=0; i<args.size(); ++i) {
const QVariant &v = args.at(i);
switch (v.type()) {
case QMetaType::QObjectStar:
l.append(wrap(qvariant_cast<QObject *>(v)));
break;
case QMetaType::VoidStar:
qWarning("QuickInterpreter::call: don't know what to do with a "
"QVariant::VoidPointer here...");
break;
default:
{
QuickScriptVariant qsvar(this, v);
if (qsvar.isNative())
l.append(qsvar.toNative());
else
l.append(qsvar);
break;
}
}
}
return call(ctx, func, l);
}
示例15: get_friends
void Widget::get_friends()
{
get_Dialog();
QUrl current("https://api.vk.com/method/friends.get");
QUrlQuery Param;
Param.addQueryItem("access_token",Setting::access_token);
Param.addQueryItem("fields","city,domain");
Param.addQueryItem("v","5.40");
current.setQuery(Param);
QByteArray answer = GET(current);
if(answer.isEmpty())
{
qDebug() << "Ничего не вернули";
exit(-1);
}
QVariantList List = parse(answer).toMap().value("response").toMap().value("items").toList();
for(int i = 0; i < List.size(); i++)
{
QVariantMap current = List[i].toMap();
QString tmp = current.value("first_name").toString() + " " + current.value("last_name").toString();
users[tmp] = current.value("id").toString();
}
for(User::iterator itr = users.begin(); itr != users.end(); itr++)
ui->FriendsList->addItem(itr.key());
emit friends_loaded(true);
}