本文整理汇总了C++中QVariant::toStringList方法的典型用法代码示例。如果您正苦于以下问题:C++ QVariant::toStringList方法的具体用法?C++ QVariant::toStringList怎么用?C++ QVariant::toStringList使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QVariant
的用法示例。
在下文中一共展示了QVariant::toStringList方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: onMessageReceived
void ClipboardMonitor::onMessageReceived(const QByteArray &message, int messageCode)
{
if (messageCode == MonitorPing) {
sendMessage( QByteArray(), MonitorPong );
#ifdef Q_OS_WIN
// Qt BUG: This needs to be called regularly so that QClipboard emits changed() signal.
QApplication::clipboard()->mimeData();
#endif
} else if (messageCode == MonitorSettings) {
QDataStream stream(message);
QVariantMap settings;
stream >> settings;
if ( hasLogLevel(LogDebug) ) {
COPYQ_LOG("Loading configuration:");
foreach (const QString &key, settings.keys()) {
QVariant val = settings[key];
const QString str = val.canConvert<QStringList>() ? val.toStringList().join(",")
: val.toString();
COPYQ_LOG( QString(" %1=%2").arg(key).arg(str) );
}
}
if ( settings.contains("formats") )
m_formats = settings["formats"].toStringList();
#ifdef COPYQ_WS_X11
m_x11->loadSettings(settings);
#endif
connect( QApplication::clipboard(), SIGNAL(changed(QClipboard::Mode)),
this, SLOT(checkClipboard(QClipboard::Mode)), Qt::UniqueConnection );
COPYQ_LOG("Configured");
} else if (messageCode == MonitorChangeClipboard) {
示例2: toUserString
QString ConversionUtil::toUserString(const QVariant &variant) {
if (!variant.isValid()) {
return "(not set)";
}
switch (variant.type()) {
case QVariant::Bool:
return variant.toBool() ? "true" : "false";
case QVariant::Int:
return QString::number(variant.toInt());
case QVariant::Double:
return QString::number(variant.toDouble());
case QVariant::String: {
QString string = variant.toString();
return string.isEmpty() ? "(empty string)" : string;
}
case QVariant::StringList:
return variant.toStringList().join("\n");
case QVariant::DateTime:
return variant.toDateTime().toString();
case QVariant::UserType: {
MetaTypeRegistry::UserStringConverters converters =
MetaTypeRegistry::userStringConverters(QMetaType::typeName(variant.userType()));
if (converters.typeToUserStringConverter) {
return converters.typeToUserStringConverter(variant);
}
} // fall-through
default:
return "(unknown type)";
}
}
示例3: updateReflectionsList
/**
* Updates the list of reflection model when an analyser bank is selected.
*
* @param index Index of the analyser selected
*/
void IndirectInstrumentConfig::updateReflectionsList(int index)
{
bool reflectionPreviousBlocking = m_uiForm.cbReflection->signalsBlocked();
m_uiForm.cbReflection->blockSignals(true);
m_uiForm.cbReflection->clear();
QVariant currentData = m_uiForm.cbAnalyser->itemData(index);
bool valid = currentData != QVariant::Invalid;
m_uiForm.cbReflection->setEnabled(valid);
if(valid)
{
QStringList reflections = currentData.toStringList();
for ( int i = 0; i < reflections.count(); i++ )
m_uiForm.cbReflection->addItem(reflections[i]);
}
else
{
m_uiForm.cbReflection->addItem("No Valid Reflections");
}
m_uiForm.cbReflection->blockSignals(reflectionPreviousBlocking);
newInstrumentConfiguration();
}
示例4: projectRunHook
void QTestLibPlugin::projectRunHook(ProjectExplorer::Project *proj)
{
return; //NBS TODO QTestlibplugin
if (!proj)
return;
m_projectDirectory = QString();
//NBS proj->setExtraApplicationRunArguments(QStringList());
//NBS proj->setCustomApplicationOutputHandler(0);
const QVariant config; //NBS = proj->projectProperty(ProjectExplorer::Constants::P_CONFIGVAR);
if (!config.toStringList().contains(QLatin1String("qtestlib")))
return;
{
QTemporaryFile tempFile;
tempFile.setAutoRemove(false);
tempFile.open();
m_outputFile = tempFile.fileName();
}
//NBS proj->setCustomApplicationOutputHandler(this);
//NBS proj->setExtraApplicationRunArguments(QStringList() << QLatin1String("-xml") << QLatin1String("-o") << m_outputFile);
const QString proFile = proj->fileName();
const QFileInfo fi(proFile);
if (QFile::exists(fi.absolutePath()))
m_projectDirectory = fi.absolutePath();
}
示例5: setAttribute
void VariantPropertyManager::setAttribute(QtProperty *property,
const QString &attribute,
const QVariant &val)
{
if (mValues.contains(property)) {
if (attribute == QLatin1String("filter")) {
if (val.type() != QVariant::String && !val.canConvert(QVariant::String))
return;
QString str = val.toString();
Data d = mValues[property];
if (d.filter == str)
return;
d.filter = str;
mValues[property] = d;
emit attributeChanged(property, attribute, str);
}
return;
}
if (mStringAttributes.contains(property)) {
if (attribute == mSuggestionsAttribute) {
mStringAttributes[property].suggestions = val.toStringList();
return;
}
if (attribute == mMultilineAttribute) {
mStringAttributes[property].multiline = val.toBool();
return;
}
}
QtVariantPropertyManager::setAttribute(property, attribute, val);
}
示例6: saveConfig
/*!
\reimp
*/
void QUsbStorageGadgetProvider::saveConfig()
{
QSettings settings("Trolltech", "Usb");
settings.beginGroup(GADGET_NAME);
QVariant v = value("product");
if (v.isValid())
settings.setValue("Product", v.toString());
v = value("productId");
if (v.isValid())
settings.setValue("ProductId", v.toUInt());
v = value("vendor");
if (v.isValid())
settings.setValue("Vendor", v.toString());
v = value("vendorId");
if (v.isValid())
settings.setValue("VendorId", v.toUInt());
v = value("backingStore");
if (v.isValid())
settings.setValue("BackingStore", v.toStringList());
settings.endGroup();
}
示例7: keysLoaded
void RedisServerDbItem::keysLoaded(const QVariant &keys, QObject *owner)
{
if (owner != this) {
return;
}
server->locked = false;
server->connection->disconnect(this);
rawKeys = keys.toStringList();
keysCount = rawKeys.size();
if (keysCount == 0) {
server->unlockUI();
setNormalIcon();
return;
}
if (keysCount < keysCount) {
server->error(QString("Loaded keys: %2 of %3. Error - %4 <br /> Check <a href='https://github.com/uglide/RedisDesktopManager/wiki/Known-issues'>documentation</a>")
.arg(keysCount)
.arg(keysCount)
.arg(server->connection->getLastError()));
}
setDbText();
renderKeys(rawKeys);
setNormalIcon();
isKeysLoaded = true;
}
示例8: set
void itemAliasList::set(ParameterList &pParams)
{
QVariant param;
bool valid;
param = pParams.value("itemType", &valid);
if (valid)
{
_itemType = param.toUInt();
setWindowTitle(buildItemLineEditTitle(_itemType, tr("Item Aliases")));
}
else
{
_itemType = ItemLineEdit::cUndefined;
setWindowTitle(tr("Item Aliases"));
}
param = pParams.value("extraClauses", &valid);
if (valid)
_extraClauses = param.toStringList();
_showInactive->setChecked(FALSE);
_showInactive->setEnabled(!(_itemType & ItemLineEdit::cActive));
param = pParams.value("sql", &valid);
if (valid)
_sql = param.toString();
}
示例9: fromVariant
/*!
Converts \a variant to a QJsonValue and returns it.
The conversion will convert QVariant types as follows:
\table
\header
\li Source type
\li Destination type
\row
\li
\list
\li QMetaType::Bool
\endlist
\li QJsonValue::Bool
\row
\li
\list
\li QMetaType::Int
\li QMetaType::UInt
\li QMetaType::LongLong
\li QMetaType::ULongLong
\li QMetaType::Float
\li QMetaType::Double
\endlist
\li QJsonValue::Double
\row
\li
\list
\li QMetaType::QString
\endlist
\li QJsonValue::String
\row
\li
\list
\li QMetaType::QStringList
\li QMetaType::QVariantList
\endlist
\li QJsonValue::Array
\row
\li
\list
\li QMetaType::QVariantMap
\endlist
\li QJsonValue::Object
\endtable
For all other QVariant types a conversion to a QString will be attempted. If the returned string
is empty, a Null QJsonValue will be stored, otherwise a String value using the returned QString.
\sa toVariant()
*/
QJsonValue QJsonValue::fromVariant(const QVariant &variant)
{
switch (variant.userType()) {
case QVariant::Bool:
return QJsonValue(variant.toBool());
case QVariant::Int:
case QMetaType::Float:
case QVariant::Double:
case QVariant::LongLong:
case QVariant::ULongLong:
case QVariant::UInt:
return QJsonValue(variant.toDouble());
case QVariant::String:
return QJsonValue(variant.toString());
case QVariant::StringList:
return QJsonValue(QJsonArray::fromStringList(variant.toStringList()));
case QVariant::List:
return QJsonValue(QJsonArray::fromVariantList(variant.toList()));
case QVariant::Map:
return QJsonValue(QJsonObject::fromVariantMap(variant.toMap()));
default:
break;
}
QString string = variant.toString();
if (string.isEmpty())
return QJsonValue();
return QJsonValue(string);
}
示例10: setValue
void Attribute::setValue( const QVariant& var )
{
if ( useRelationTable() ) {
QSqlQuery q;
QString query = "SELECT " + mIdCol +" FROM " + mTable + " WHERE " + mStringCol + "=:string";
q.prepare( query );
// kDebug() << "Column: " << mIdCol << " | table " << mTable << " | string: " << mStringCol << ": " << query;
if ( listValue() ) {
QStringList idList;
QStringList list = var.toStringList();
for ( QStringList::Iterator valIt = list.begin(); valIt != list.end(); ++valIt ) {
QString curValue = *valIt;
// kDebug() << "Searching for " << curValue << " in relation table";
q.bindValue( ":string", curValue );
q.exec();
if ( q.next() ) {
idList << q.value( 0 ).toString();
}
}
mValue = QVariant( idList );
} else {
q.bindValue( ":string", var.toString() );
q.exec();
// kDebug() << "ERROR" << q.lastError().text();
if ( q.next() ) {
mValue = q.value( 0 );
}
}
} else {
mValue = var;
}
}
示例11:
QHash<QString, QString> VConfigManager::readShortcutsFromSettings(QSettings *p_settings,
const QString &p_group)
{
QHash<QString, QString> ret;
p_settings->beginGroup(p_group);
QStringList keys = p_settings->childKeys();
for (auto const & key : keys) {
if (key.isEmpty()) {
continue;
}
QVariant varVal = p_settings->value(key);
QString sequence = varVal.toString();
if (varVal.type() == QVariant::StringList) {
sequence = varVal.toStringList().join(",");
}
sequence = sequence.trimmed();
if (isValidKeySequence(sequence)) {
ret.insert(key, sequence);
}
}
p_settings->endGroup();
return ret;
}
示例12: loadSetting
QVariant Sailwave::loadSetting(const QString &key, const QVariant &defaultValue)
{
this->_settings->sync();
QVariant value = this->_settings->value(key, defaultValue);
// Ugly hack. Type of value is not correct - so use type of defaultValue, assuming that this is the correct type...
switch (defaultValue.type()) {
case QVariant::Bool:
return value.toBool();
case QVariant::Double:
return value.toDouble();
case QVariant::Int:
return value.toInt();
case QVariant::String:
return value.toString();
case QVariant::StringList:
return value.toStringList();
case QVariant::List:
return value.toList();
default:
return value;
}
}
示例13: variantToSetting
static InspectorController::Setting variantToSetting(const QVariant& qvariant)
{
InspectorController::Setting retVal;
switch (qvariant.type()) {
case QVariant::Bool:
retVal.set(qvariant.toBool());
break;
case QVariant::Double:
retVal.set(qvariant.toDouble());
break;
case QVariant::Int:
retVal.set((long)qvariant.toInt());
break;
case QVariant::String:
retVal.set(qvariant.toString());
break;
case QVariant::StringList: {
QStringList qsList = qvariant.toStringList();
int listCount = qsList.count();
Vector<String> vector(listCount);
for (int i = 0; i < listCount; ++i)
vector[i] = qsList[i];
retVal.set(vector);
break;
}
}
return retVal;
}
示例14: loadRecents
void BackStageForm::loadRecents()
{
_settings.sync();
QVariant v = _settings.value("recentItems");
if (v.type() != QVariant::StringList && v.type() != QVariant::String)
{
// oddly, under linux, loading a setting value of type StringList which has
// only a single string in it, gives you just a string. we QVariant::String is acceptable too
qDebug() << "BackStageForm::loadRecents(); setting 'recentItems' is not a QStringList";
return;
}
QStringList recents = v.toStringList();
for (int i = 0; i < recents.size(); i++)
{
if (!QFileInfo::exists(recents[i]))
{
recents.removeAt(i);
i -= 1;
}
}
while (_recents.size() > 5)
_recents.removeFirst();
if (recents != _recents)
{
_recents = recents;
ui->recentDataSets->setDataSets(_recents);
}
}
示例15: list
VCXYPadFixture::VCXYPadFixture(const QVariant& variant)
{
if (variant.canConvert(QVariant::StringList) == true)
{
QStringList list(variant.toStringList());
if (list.count() == 7)
{
m_fixture = list.at(0).toInt();
m_xMin = list.at(1).toDouble();
m_xMax = list.at(2).toDouble();
m_xReverse = list.at(3).toInt();
m_yMin = list.at(4).toDouble();
m_yMax = list.at(5).toDouble();
m_yReverse = list.at(6).toInt();
}
else
{
/* Construct empty fixture */
*this = VCXYPadFixture();
}
}
else
{
/* Construct empty fixture */
*this = VCXYPadFixture();
}
m_xMSB = KChannelInvalid;
m_xLSB = KChannelInvalid;
m_yMSB = KChannelInvalid;
m_yLSB = KChannelInvalid;
}