本文整理汇总了C++中QVariantList::length方法的典型用法代码示例。如果您正苦于以下问题:C++ QVariantList::length方法的具体用法?C++ QVariantList::length怎么用?C++ QVariantList::length使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QVariantList
的用法示例。
在下文中一共展示了QVariantList::length方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: qDebug
QJSValue THREEMatrix4::applyVector3Array(QJSValue floatArray, int offset, int length)
{
if(!floatArray.isArray()) {
qDebug().nospace() << "THREEMatrix4::" << __FUNCTION__
<< " invalid parameter type for floatArray, expected JS array";
return m_engine->newQObject(this);
}
static THREEVector3 v1(parent(), m_engine);
QVariantList list = floatArray.toVariant().toList();
if (offset < 0)
offset = 0;
if (length < 0 || length == 0)
length = list.length();
if (offset + length > list.length())
length = list.length() - offset;
for ( int i = 0, j = offset; i < length; i += 3, j += 3 ) {
v1.m_x = float(floatArray.property(j).toNumber());
v1.m_y = float(floatArray.property(j + 1).toNumber());
v1.m_z = float(floatArray.property(j + 2).toNumber());
v1._applyMatrix4( this );
floatArray.setProperty(j, QJSValue(v1.m_x));
floatArray.setProperty(j + 1, QJSValue(v1.m_y));
floatArray.setProperty(j + 2, QJSValue(v1.m_z));
}
return floatArray;
}
示例2: onAlllineDataModelFinished
void NetworkBus::onAlllineDataModelFinished(QNetworkReply* reply){
if(reply->error() != QNetworkReply::NoError){
m_error = QString::fromUtf8("所有线路数据请求错误,请检查网络后重试!");
onError();
reply->deleteLater();
return;
}else{
JsonDataAccess jda; // at are you
const QVariant qtData = jda.loadFromBuffer(reply->readAll());
// TODO if qtData has some error
const QVariantMap map = qtData.toMap();
const QString msg = map.values("msg").value(0).toString();
const QString success = map.values("success").value(0).toString();
if(success != "true" || msg != "ok"){
m_error = QString::fromUtf8("所有线路数据返回不成功,请检查网络后重试!");
onError();
reply->deleteLater();
return;
}
//
const QVariantList data = map["data"].toList();
if(data.isEmpty() || data.length() == 0){
m_error = QString::fromUtf8("未查询到所有公交车线路数据!");
onError();
reply->deleteLater();
return ;
}
QString result = "";
m_alllineDataModel->clear();
for(int i=0;i<data.length();i++){
const QVariantMap iMap = data.at(i).toMap();
busline *bus = new busline;
bus->setBeginTime(iMap.value("begin_time").toString());
bus->setEndTime(iMap.value("end_time").toString());
bus->setId(iMap.value("id").toString());
bus->setStartStation(iMap.value("start_station").toString());
bus->setEndStation(iMap.value("end_station").toString());
bus->setPrice(iMap.value("price").toString());
bus->setLineName(iMap.value("line_name").toString());
bus->setIsOpen(iMap.value("isopen").toInt());//1
bus->setDir(iMap.value("dir").toInt());//0/1
bus->setCityId(m_city_id);
if(bus->getIsOpen() == 1)
m_alllineDataModel->append(bus);
}
reply->deleteLater();
}
qDebug()<< "m_allline datamodel size:" << m_alllineDataModel->size();
m_error = QString::fromUtf8("查询到所有公交车线路数据!");
this->setProcess(false);
emit processChanged();
emit alllineDataModelChanged();
}
示例3: tTemplateWidget
//-----------------------------------------------------------------------------
//!
//-----------------------------------------------------------------------------
tDualAnalogWidget::tDualAnalogWidget( int pageNumber, tIInstrumentProductFactory* pProductFactory, QWidget* pParent )
: tTemplateWidget( pProductFactory, pageNumber, pParent )
, m_LeftLimitIndex( 0 )
, m_RightLimitIndex( 0 )
{
Assert( pProductFactory );
if ( pProductFactory )
{
QVariantList analogRanges = tWidgetSettings::Instance()->TemplateAnalogRanges( m_PageNumber );
if( analogRanges.length() > 0 )
{
m_LeftLimitIndex = analogRanges[0].toInt();
}
if( analogRanges.length() > 1 )
{
m_RightLimitIndex = analogRanges[1].toInt();
}
m_pAnalogGauge1 = pProductFactory->GetAnalogGauge( DATA_TYPE_INVALID, this );
m_pAnalogGauge1->SetCustomHobartLimits( m_LeftLimitIndex );
m_pLayout->addWidget( m_pAnalogGauge1, 0, 0, 2, 1 );
m_Gauges << m_pAnalogGauge1;
m_pAnalogGauge2 = pProductFactory->GetAnalogGauge( DATA_TYPE_INVALID, this );
m_pAnalogGauge2->SetCustomHobartLimits( m_RightLimitIndex );
m_pLayout->addWidget( m_pAnalogGauge2, 1, 1, 1, 2 );
m_Gauges << m_pAnalogGauge2;
m_pDigitalGauge1 = pProductFactory->GetDigitalGauge( DATA_TYPE_INVALID, this );
m_pDigitalGauge1->SetBorders( false, false, true, false );
m_pLayout->addWidget( m_pDigitalGauge1, 0, 1 );
m_Gauges << m_pDigitalGauge1;
m_pDigitalGauge2 = pProductFactory->GetDigitalGauge( DATA_TYPE_INVALID, this );
m_pDigitalGauge2->SetBorders( false );
m_pLayout->addWidget( m_pDigitalGauge2, 0, 2 );
m_Gauges << m_pDigitalGauge2;
int analog1H = Widgets::GetScreenHeight();
int analog1W = analog1H;
int analog2W = Widgets::GetScreenWidth() - analog1W;
int analog2H = analog2W;
int digitalH = Widgets::GetScreenHeight() - analog2H;
int digitalW = analog2W / 2;
m_pAnalogGauge1 ->setFixedSize( analog1W, analog1H );
m_pAnalogGauge2 ->setFixedSize( analog2W, analog2H );
m_pDigitalGauge1 ->setFixedSize( digitalW, digitalH );
m_pDigitalGauge2 ->setFixedSize( digitalW, digitalH );
LoadDataItems();
}
}
示例4: onSublineInfFinished
//! [1]
void NetworkBus::onSublineInfFinished(QNetworkReply* reply){
if(reply->error() != QNetworkReply::NoError){
m_error = QString::fromUtf8("站点信息请求失败,请检查网络后重试!");
onError();
reply->deleteLater();
return ;
}else{
JsonDataAccess jda; // at are you
const QVariant qtData = jda.loadFromBuffer(reply->readAll());
// TODO if qtData has some error
const QVariantMap map = qtData.toMap();
const QString msg = map.values("msg").value(0).toString();
const QString success = map.values("success").value(0).toString();
if(success != "true" || msg != "ok"){
m_error = QString::fromUtf8("站点信息返回不成功,请稍后重试!");
onError();
reply->deleteLater();
return;
}
const QVariantMap data = map["data"].toMap();
const QVariantList stations = data["stations"].toList();
if(stations.isEmpty() || stations.length() == 0){
m_error = QString::fromUtf8("未查询到站点数据!");
onError();
reply->deleteLater();
return ;
}
m_dataModel->clear();
for(int i=0;i<stations.length();i++){
const QVariantMap var = stations.at(i).toMap();
station *sta = new station();
sta->setCode(var["code"].toString());
sta->setId(var["id"].toString());
sta->setLat(var["lat"].toString());
sta->setLng(var["lng"].toString());
// QString name = QString::number(i+1) ;
// name.append(var["name"].toString());
sta->setIndex(QString::number(i+1));
// qDebug() << "name string : " << name ;
sta->setName(var["name"].toString());
if(m_dir == 0)
startStation->append(sta);
else endStation->append(sta);
}
m_dataModel->append(m_dir == 0 ? *startStation : *endStation);
}
qDebug() << "\nm_dataModel size :"<<m_dataModel->size() << "\n";
emit dataModelChanged();
emit buslineChanged();
reply->deleteLater();
this->get_lineisopen();
}
示例5: oscColorNote
//---------------------------------------------------------
// oscColorNote
//---------------------------------------------------------
void MuseScore::oscColorNote(QVariantList list)
{
qDebug() << list;
if(!cs)
return;
if (list.length() != 2 && list.length() != 3)
return;
int tick;
int pitch;
QColor noteColor("red"); //default to red
bool ok;
tick = list[0].toInt(&ok);
if (!ok)
return;
pitch = list[1].toInt(&ok);
if (!ok)
return;
if(list.length() == 3 && list[2].canConvert(QVariant::String)) {
QColor color(list[2].toString());
if(color.isValid())
noteColor = color;
}
Measure* measure = cs->tick2measure(tick);
if(!measure)
return;
Segment* s = measure->findSegment(Segment::SegChordRest, tick);
if (!s)
return;
//get all chords in segment...
int n = cs->nstaves() * VOICES;
for (int i = 0; i < n; i++) {
Element* e = s->element(i);
if (e && e->isChordRest()) {
ChordRest* cr = static_cast<ChordRest*>(e);
if(cr->type() == Element::CHORD) {
Chord* chord = static_cast<Chord*>(cr);
for (int idx = 0; idx < chord->notes().length(); idx++) {
Note* note = chord->notes()[idx];
if (note->pitch() == pitch) {
cs->startCmd();
cs->undo(new ChangeProperty(note, P_COLOR, noteColor));
cs->endCmd();
cs->end();
return;
}
}
}
}
}
}
示例6: packetChanged
bool model::Network::emitNetwork(XMASNetwork &network) {
auto &componentMap = network.getComponentMap();
std::clock_t c_start = std::clock();
QVariantList compList;
for(auto &it : componentMap) {
XMASComponent *comp = it.second;
if (comp) {
QVariantMap map;
convertToQml(map, comp);
compList.append(map);
}
}
QVariantList channelList;
for (auto &it : componentMap) {
XMASComponent *comp = it.second;
if (comp) {
QVariantList list;
connectInQml(list, comp);
channelList.append(list);
}
}
QVariantMap qmlNetwork;
qmlNetwork["complist"] = compList;
qmlNetwork["channellist"] = channelList; emit packetChanged();
emit packetChanged();
// Var is not implemented in qml yet. No known semantics for var
//qmlNetwork["var"] = QString(network.getVar().stl().c_str());
auto cne = network.getNetworkExtension<CompositeNetworkExtension>(false);
if(cne){
this->m_alias = cne->alias.c_str();
this->m_boxedImage = cne->boxedImage;
this->m_imageName = cne->imageName.c_str();
}
auto cve = network.getNetworkExtension<CanvasNetworkExtension>(false);
if(cve){
this->m_size = QSize(cve->width,cve->height);
}
emit createNetwork(qmlNetwork);
std::clock_t c_end = std::clock();
qDebug() << "CPU time used: " << 1000.0 * (c_end-c_start) / CLOCKS_PER_SEC << " ms"
<< " for " << compList.length() << " components and " << channelList.length() << " channels";
return true;
}
示例7: bindParameters
static void bindParameters(const QVariantList& bindValues, QSqlQuery *sqlQuery) {
if (!bindValues.isEmpty()) {
for (int i = bindValues.length() - 1; i >= 0; --i) {
sqlQuery->bindValue(i, bindValues.at(i));
}
}
}
示例8: qDebug
void Bb10Ui::onChannelListTriggered(const QVariantList index)
{
// Headers are not clickable
if (index.length() < 2)
return;
QModelIndex modelIndex = qobject_cast<DataModelAdapter*>(m_channelListView->dataModel())->getQModelIndex(index);
BufferInfo bufferInfo = modelIndex.data(NetworkModel::BufferInfoRole).value<BufferInfo>();
BufferId id = bufferInfo.bufferId();
if (!id.isValid())
return;
QString bufferName = bufferInfo.bufferName();
qDebug() << "xxxxx Bb10Ui::onChannelListTriggered bufferInfo = " << bufferInfo << " index = " << index << " modelIndex = " << modelIndex;
ChatView *view = qobject_cast<ChatView *>(m_chatViews.value(id));
if (!view) {
view = new ChatView(id, bufferName);
m_chatViews[id] = view;
}
m_currentBufferId = id;
Client::bufferModel()->switchToBuffer(id);
Client::networkModel()->clearBufferActivity(id);
Client::setBufferLastSeenMsg(id, view->getLastMsgId());
Client::backlogManager()->checkForBacklog(id);
navPanePush(view->getPage());
// ask channelListView to update the appearance
qobject_cast<DataModelAdapter*>(m_channelListView->dataModel())->handleBufferModelDataChanged(modelIndex, modelIndex);
}
示例9: createEntries
/*
* Create files/directories based on the provided array
*/
void FileEngine::createEntries(const QString &jsonString)
{
QVariantList entryList = QJsonDocument::fromJson(QByteArray(jsonString.toLatin1())).array().toVariantList();
for (int i=0; i < entryList.length(); i++)
{
QMap<QString, QVariant> entryMap = entryList.at(i).toMap();
QString type = entryMap.value("type").toString();
QString path = entryMap.value("path").toString();
QString name = entryMap.value("name").toString();
// Create directories
if (type == "directory")
{
QDir dir(path);
bool success = dir.mkdir(QString("%1/%2").arg(path, name));
}
else if (type == "file")
{
QFile file(QString("%1/%2").arg(path, name));
file.open(QFile::WriteOnly);
}
}
}
示例10: echoRequestTest
void tst_JsonRpcConnection::echoRequestTest()
{
mIODevice = new MockIODevice("data/echoRequest.jsonrpc");
mConnection = new JsonRpcConnection(mIODevice);
connect(mConnection, SIGNAL(disconnected()), SLOT(onDisconnected()));
QSignalSpy requestReceivedSpy(mConnection, SIGNAL(requestReceived(const JsonRpcMessage &)));
QSignalSpy responseReceivedSpy(mConnection, SIGNAL(responseReceived(const JsonRpcMessage &)));
QSignalSpy disconnectedSpy(mConnection, SIGNAL(disconnected()));
QList<QVariant> arguments;
mIODevice->open(QIODevice::ReadWrite);
mEventLoop.exec();
QVERIFY(requestReceivedSpy.count() == 1);
QVERIFY(responseReceivedSpy.count() == 0);
QVERIFY(disconnectedSpy.count() == 1);
JsonRpcMessage request;
arguments = requestReceivedSpy.takeFirst();
request = arguments.at(0).value<JsonRpcMessage>();
QCOMPARE(request.idAsVariant().toUInt(), (quint32)1);
QCOMPARE(request.method(), QString("echo"));
QVariantList params = request.parameters();
QVERIFY(params.length() == 1);
QCOMPARE(params.at(0).toString(), QString("Hello JSON-RPC"));
}
示例11: QStringList
BattleChoice fromJson<BattleChoice>(const QVariantMap &v){
static QStringList bchoices = QStringList() << "cancel" << "attack" << "switch" << "rearrange" << "shiftcenter" << "tie" << "item";
BattleChoice info;
info.type = std::max(bchoices.indexOf(v.value("type").toString()), 0);
info.playerSlot = v.value("slot").toInt();
if (info.type == AttackType) {
info.choice.attack.attackSlot = v.value("attackSlot").toInt();
info.choice.attack.mega = v.value("mega").toBool();
if (v.value("target").isValid()) {
info.choice.attack.attackTarget = v.value("target").toInt();
} else {
info.choice.attack.attackTarget = !info.playerSlot;
}
} else if (info.type == SwitchType) {
info.choice.switching.pokeSlot = v.value("pokeSlot").toInt();
} else if (info.type == RearrangeType) {
if (v.value("neworder").canConvert<QVariantList>()) {
QVariantList list = v.value("neworder").toList();
for (int i = 0; i < list.length() && i < 6; i++) {
info.choice.rearrange.pokeIndexes[i] = list.value(i).toInt();
}
}
} else if (info.type == ItemType) {
info.choice.item.item = v.value("item").toInt();
info.choice.item.target = v.value("target").toInt();
info.choice.item.attack = v.value("attack").toInt();
}
return info;
}
示例12: buildInactiveProjectList
int BdLogic::buildInactiveProjectList()
{
QVariantMap resourcesMapFromJson;
QVariantList projectListFromJson;
QVariantMap projectFromJson;
resourcesMapFromJson = m_boxMapParsedJson[BoxNames[DLSTATE_RESOURCES]].toMap();
resourcesMapFromJson = resourcesMapFromJson["resources"].toMap();
projectListFromJson = resourcesMapFromJson["projects"].toList();
m_currentInactiveProjectDlIx = 0;
m_inactiveProjectUUIDList.clear();
for(int projectIx = 0; projectIx < projectListFromJson.length(); projectIx++)
{
projectFromJson = projectListFromJson[projectIx].toMap();
if(projectFromJson["status"].toString() == QString("inactive"))
{
m_inactiveProjectUUIDList.push_back(projectFromJson["uuid"].toString());
}
}
return BDLOGIC_STATUS_OK;
}
示例13: gotHeaders
void KRemoteModel::gotHeaders(QVariantList headers) {
if(st_ == Headers) {
emit beginInsertColumns(QModelIndex(), 0, headers.length() - 1);
hdrs_ = headers;
emit endInsertColumns();
setState(Fetching);
}
}
示例14: addArray
void JsonSerializer::addArray(const QVariantList &list) {
m_buffer.append("[");
for (int i = 0; i < list.length(); i++) {
if (i > 0)
m_buffer.append(",");
addVariant(list[i]);
}
m_buffer.append("]");
}
示例15: restore
void QxCommand::restore(QVariantList list)
{
int i = 0;
icon_.loadFromData(list.at(i++).toByteArray(), "PNG");
description_ = list.at(i++).toString();
keys_ = list.at(i++).toString();
script_ = list.at(i++).toString();
target_ = list.at(i++).toInt();
if (i < list.length()) {
autoSaveFile_ = list.at(i++).toBool();
if (i < list.length())
autoOpenNextLink_ = list.at(i++).toBool();
else
autoOpenNextLink_ = false;
}
else
autoSaveFile_ = false;
}