本文整理汇总了C++中QVariant::toLine方法的典型用法代码示例。如果您正苦于以下问题:C++ QVariant::toLine方法的具体用法?C++ QVariant::toLine怎么用?C++ QVariant::toLine使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QVariant
的用法示例。
在下文中一共展示了QVariant::toLine方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: QString
//.........这里部分代码省略.........
ds << (quint32)value.toUInt();
else
ds << (quint64)value.toUInt();
break;
case QVariant::String:
ds << typeName;
ds << value.toString();
break;
case QVariant::Pixmap:
ds << typeName;
ds << value.value<QPixmap>();
break;
case QVariant::ByteArray:
ds << typeName;
ds << value.toByteArray();
break;
case QVariant::BitArray:
ds << typeName;
ds << value.toBitArray();
break;
case QVariant::Image:
ds << typeName;
ds << value.value<QImage>();
break;
case QVariant::Url:
ds << typeName;
ds << value.toUrl();
break;
case QVariant::StringList:
ds << typeName;
ds << value.toStringList();
break;
case QVariant::SizePolicy:
ds << typeName;
ds << value.value<QSizePolicy>();
break;
case QVariant::SizeF:
ds << typeName;
ds << value.toSizeF();
break;
case QVariant::Size:
ds << typeName;
ds << value.toSize();
break;
case QVariant::RegExp:
ds << typeName;
ds << value.toRegExp();
break;
case QVariant::RectF:
ds << typeName;
ds << value.toRectF();
break;
case QVariant::Rect:
ds << typeName;
ds << value.toRect();
break;
case QVariant::Polygon:
ds << typeName;
ds << value.value<QPolygon>();
break;
case QVariant::PointF:
ds << typeName;
ds << value.toPointF();
break;
case QVariant::Point:
ds << typeName;
ds << value.toPoint();
break;
case QVariant::Matrix:
ds << typeName;
ds << value.value<QMatrix>();
break;
case QVariant::LineF:
ds << typeName;
ds << value.toLineF();
break;
case QVariant::Line:
ds << typeName;
ds << value.toLine();
break;
case QVariant::Brush:
ds << typeName;
ds << value.value<QBrush>();
break;
case QVariant::Bitmap:
ds << typeName;
ds << value.value<QBitmap>();
break;
case QVariant::Transform:
ds << typeName;
ds << value.value<QTransform>();
break;
default:
// Other types will be supported shortly.
// TODO: support user defined types.
return false;
}
return true;
}
示例2: displayString
QString VariantHandler::displayString(const QVariant& value)
{
switch (value.type()) {
#ifndef QT_NO_CURSOR
case QVariant::Cursor:
{
const QCursor cursor = value.value<QCursor>();
return Util::enumToString(QVariant::fromValue<int>(cursor.shape()), "Qt::CursorShape");
}
#endif
case QVariant::Icon:
{
const QIcon icon = value.value<QIcon>();
if (icon.isNull()) {
return QObject::tr("<no icon>");
}
QStringList l;
foreach (const QSize &size, icon.availableSizes()) {
l.push_back(displayString(size));
}
return l.join(QLatin1String(", "));
}
case QVariant::Line:
return
QString::fromUtf8("%1 x %2 → %3 x %4").
arg(value.toLine().x1()).arg(value.toLine().y1()).
arg(value.toLine().x2()).arg(value.toLine().y2());
case QVariant::LineF:
return
QString::fromUtf8("%1 x %2 → %3 x %4").
arg(value.toLineF().x1()).arg(value.toLineF().y1()).
arg(value.toLineF().x2()).arg(value.toLineF().y2());
case QVariant::Locale:
return value.value<QLocale>().name();
case QVariant::Point:
return
QString::fromLatin1("%1x%2").
arg(value.toPoint().x()).
arg(value.toPoint().y());
case QVariant::PointF:
return
QString::fromLatin1("%1x%2").
arg(value.toPointF().x()).
arg(value.toPointF().y());
case QVariant::Rect:
return
QString::fromLatin1("%1x%2 %3x%4").
arg(value.toRect().x()).
arg(value.toRect().y()).
arg(value.toRect().width()).
arg(value.toRect().height());
case QVariant::RectF:
return
QString::fromLatin1("%1x%2 %3x%4").
arg(value.toRectF().x()).
arg(value.toRectF().y()).
arg(value.toRectF().width()).
arg(value.toRectF().height());
case QVariant::Region:
{
const QRegion region = value.value<QRegion>();
if (region.isEmpty()) {
return QLatin1String("<empty>");
}
if (region.rectCount() == 1) {
return displayString(region.rects().first());
} else {
return QString::fromLatin1("<%1 rects>").arg(region.rectCount());
}
}
case QVariant::Palette:
{
const QPalette pal = value.value<QPalette>();
if (pal == qApp->palette()) {
return QLatin1String("<inherited>");
}
return QLatin1String("<custom>");
}
case QVariant::Size:
return
QString::fromLatin1("%1x%2").
arg(value.toSize().width()).
arg(value.toSize().height());
case QVariant::SizeF:
return
QString::fromLatin1("%1x%2").
arg(value.toSizeF().width()).
arg(value.toSizeF().height());
case QVariant::StringList:
//.........这里部分代码省略.........
示例3: tr
QString GammaRay::Util::variantToString(const QVariant &value)
{
switch (value.type()) {
case QVariant::Icon:
{
const QIcon icon = value.value<QIcon>();
if (icon.isNull())
return QObject::tr("<no icon>");
QStringList l;
foreach (const QSize &size, icon.availableSizes())
l.push_back(variantToString(size));
return l.join(QLatin1String(", "));
}
case QVariant::Line:
return QString::fromUtf8("%1 x %2 → %3 x %4")
.arg(value.toLine().x1()).arg(value.toLine().y1())
.arg(value.toLine().x2()).arg(value.toLine().y2());
case QVariant::LineF:
return QString::fromUtf8("%1 x %2 → %3 x %4")
.arg(value.toLineF().x1()).arg(value.toLineF().y1())
.arg(value.toLineF().x2()).arg(value.toLineF().y2());
case QVariant::Point:
return QString::fromLatin1("%1x%2").
arg(value.toPoint().x()).
arg(value.toPoint().y());
case QVariant::PointF:
return QString::fromLatin1("%1x%2").
arg(value.toPointF().x()).
arg(value.toPointF().y());
case QVariant::Rect:
return QString::fromLatin1("%1x%2 %3x%4").
arg(value.toRect().x()).
arg(value.toRect().y()).
arg(value.toRect().width()).
arg(value.toRect().height());
case QVariant::RectF:
return QString::fromLatin1("%1x%2 %3x%4").
arg(value.toRectF().x()).
arg(value.toRectF().y()).
arg(value.toRectF().width()).
arg(value.toRectF().height());
case QVariant::Region:
{
const QRegion region = value.value<QRegion>();
if (region.isEmpty()) {
return QLatin1String("<empty>");
}
if (region.rectCount() == 1) {
return variantToString(region.rects().first());
} else {
return QString::fromLatin1("<%1 rects>").arg(region.rectCount());
}
}
case QVariant::Palette:
{
const QPalette pal = value.value<QPalette>();
if (pal == qApp->palette())
return QLatin1String("<inherited>");
return QLatin1String("<custom>");
}
case QVariant::Size:
return QString::fromLatin1("%1x%2").
arg(value.toSize().width()).
arg(value.toSize().height());
case QVariant::SizeF:
return QString::fromLatin1("%1x%2").
arg(value.toSizeF().width()).
arg(value.toSizeF().height());
case QVariant::SizePolicy:
return QString::fromLatin1("%1 x %2").
arg(sizePolicyToString(value.value<QSizePolicy>().horizontalPolicy())).
arg(sizePolicyToString(value.value<QSizePolicy>().verticalPolicy()));
case QVariant::StringList:
return value.toStringList().join(", ");
case QVariant::Transform:
{
const QTransform t = value.value<QTransform>();
return QString::fromLatin1("[%1 %2 %3, %4 %5 %6, %7 %8 %9]").
arg(t.m11()).arg(t.m12()).arg(t.m13()).
arg(t.m21()).arg(t.m22()).arg(t.m23()).
arg(t.m31()).arg(t.m32()).arg(t.m33());
}
default:
break;
}
// types with dynamic type ids
if (value.type() == qMetaTypeId<QTextLength>()) {
//.........这里部分代码省略.........
示例4: displayString
QString VariantHandler::displayString(const QVariant &value)
{
switch (value.type()) {
#ifndef QT_NO_CURSOR
case QVariant::Cursor:
{
const QCursor cursor = value.value<QCursor>();
return Util::enumToString(QVariant::fromValue<int>(cursor.shape()), "Qt::CursorShape");
}
#endif
case QVariant::Icon:
{
const QIcon icon = value.value<QIcon>();
if (icon.isNull()) {
return QObject::tr("<no icon>");
}
QStringList l;
foreach (const QSize &size, icon.availableSizes()) {
l.push_back(displayString(size));
}
return l.join(QLatin1String(", "));
}
case QVariant::Line:
return
QString::fromUtf8("%1, %2 → %3, %4").
arg(value.toLine().x1()).arg(value.toLine().y1()).
arg(value.toLine().x2()).arg(value.toLine().y2());
case QVariant::LineF:
return
QString::fromUtf8("%1, %2 → %3, %4").
arg(value.toLineF().x1()).arg(value.toLineF().y1()).
arg(value.toLineF().x2()).arg(value.toLineF().y2());
case QVariant::Locale:
return value.value<QLocale>().name();
case QVariant::Point:
return
QString::fromLatin1("%1, %2").
arg(value.toPoint().x()).
arg(value.toPoint().y());
case QVariant::PointF:
return
QString::fromLatin1("%1, %2").
arg(value.toPointF().x()).
arg(value.toPointF().y());
case QVariant::Rect:
return
QString::fromLatin1("%1, %2 %3 x %4").
arg(value.toRect().x()).
arg(value.toRect().y()).
arg(value.toRect().width()).
arg(value.toRect().height());
case QVariant::RectF:
return
QString::fromLatin1("%1, %2 %3 x %4").
arg(value.toRectF().x()).
arg(value.toRectF().y()).
arg(value.toRectF().width()).
arg(value.toRectF().height());
case QVariant::Region:
{
const QRegion region = value.value<QRegion>();
if (region.isEmpty()) {
return QLatin1String("<empty>");
}
if (region.rectCount() == 1) {
return displayString(region.rects().first());
} else {
return QString::fromLatin1("<%1 rects>").arg(region.rectCount());
}
}
case QVariant::Palette:
{
const QPalette pal = value.value<QPalette>();
if (pal == qApp->palette()) {
return QLatin1String("<inherited>");
}
return QLatin1String("<custom>");
}
case QVariant::Size:
return
QString::fromLatin1("%1 x %2").
arg(value.toSize().width()).
arg(value.toSize().height());
case QVariant::SizeF:
return
QString::fromLatin1("%1 x %2").
arg(value.toSizeF().width()).
arg(value.toSizeF().height());
case QVariant::StringList:
//.........这里部分代码省略.........
示例5: printMes
void PSV_Public::printMes(const QVariant &mes, const QString &frefix)
{
QString message;
int type = mes.type();
switch(type)
{
case QVariant::Bool :
message = mes.toBool() ? "true":"false";
break;
case QVariant::Color :
{
QColor color = mes.value<QColor>();
message = QObject::tr("colorname:%1,r=%2,g=%3,b=%4")
.arg(color.name())
.arg(color.red())
.arg(color.green())
.arg(color.blue());
}
break;
case QVariant::Date:
message = mes.toDate().toString("yyyy-MM-dd");
break;
case QVariant::DateTime:
message = mes.toDateTime().toString("yyyy-MM-dd hh:mm:ss");
break;
case QVariant::Double:
message = QString::number(mes.toDouble());
break;
case QVariant::UInt:
case QVariant::Int:
message = QString::number(mes.toInt());
break;
case QVariant::ULongLong:
case QVariant::LongLong:
message = QString::number(mes.toLongLong());
break;
case QVariant::Line:
{
QLine line = mes.toLine();
message = QObject::tr("Line x1=%1,y1=%2,x2=%3,y2=%4")
.arg(line.x1()).arg(line.y1()).arg(line.x2()).arg(line.y2());
}
break;
case QVariant::LineF:
{
QLineF lineF = mes.toLineF();
message = QObject::tr("LineF x1=%1,y1=%2,x2=%3,y2=%4")
.arg(lineF.x1()).arg(lineF.y1()).arg(lineF.x2()).arg(lineF.y2());
}
break;
case QVariant::Point:
{
QPoint point = mes.toPoint();
message = QObject::tr("point x=%1,y=%2")
.arg(point.x()).arg(point.y());
}
break;
case QVariant::PointF:
{
QPointF pointF = mes.toPointF();
message = QObject::tr("pointF x=%1,y=%2")
.arg(pointF.x()).arg(pointF.y());
}
break;
case QVariant::Rect:
{
QRect rect = mes.toRect();
message = QObject::tr("rect x=%1,y=%2,width=%3,height=%4")
.arg(rect.x()).arg(rect.y()).arg(rect.width()).arg(rect.height());
}
break;
case QVariant::RectF:
{
QRectF rectF = mes.toRect();
message = QObject::tr("rectF x=%1,y=%2,width=%3,height=%4")
.arg(rectF.x()).arg(rectF.y()).arg(rectF.width()).arg(rectF.height());
}
break;
default:
message = QObject::tr("type = %1,<%2>").arg(type).arg(mes.toString());
break;
}
QString outMes = QObject::tr("%1 %2").arg(frefix).arg(message);
qDebug()<<QObject::tr("PSV_LIB:<%1>%2").arg(QDateTime::currentDateTime().toString("yyyy-MM-dd hh:mm:ss")).arg(outMes);
}