本文整理汇总了C++中QVariant::toPoint方法的典型用法代码示例。如果您正苦于以下问题:C++ QVariant::toPoint方法的具体用法?C++ QVariant::toPoint怎么用?C++ QVariant::toPoint使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QVariant
的用法示例。
在下文中一共展示了QVariant::toPoint方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: onActionMouseInOut
void KNMusicHeaderPlayer::onActionMouseInOut(const QVariant &controlPos)
{
QPoint controlPosition=controlPos.toPoint();
m_textPalette.setColor(QPalette::WindowText, QColor(255,255,255,-controlPosition.y()*5));
m_title->setPalette(m_textPalette);
m_artistAlbum->setPalette(m_textPalette);
}
示例2: inputMethodQuery
/*!
\internal
Reimplemented from QGraphicsItemPrivate. ### Qt 5: Move impl to
reimplementation QGraphicsProxyWidget::inputMethodQuery().
*/
QVariant QGraphicsProxyWidgetPrivate::inputMethodQueryHelper(Qt::InputMethodQuery query) const
{
Q_Q(const QGraphicsProxyWidget);
if (!widget || !q->hasFocus())
return QVariant();
QWidget *focusWidget = widget->focusWidget();
if (!focusWidget)
focusWidget = widget;
QVariant v = focusWidget->inputMethodQuery(query);
QPointF focusWidgetPos = q->subWidgetRect(focusWidget).topLeft();
switch (v.type()) {
case QVariant::RectF:
v = v.toRectF().translated(focusWidgetPos);
break;
case QVariant::PointF:
v = v.toPointF() + focusWidgetPos;
break;
case QVariant::Rect:
v = v.toRect().translated(focusWidgetPos.toPoint());
break;
case QVariant::Point:
v = v.toPoint() + focusWidgetPos.toPoint();
break;
default:
break;
}
return v;
}
示例3: setValue
void KPointComposedProperty::setValue(KProperty *property,
const QVariant &value, bool rememberOldValue)
{
const QPoint p( value.toPoint() );
property->child("x")->setValue(p.x(), rememberOldValue, false);
property->child("y")->setValue(p.y(), rememberOldValue, false);
}
示例4: setOption
bool EnlargeShrink::setOption(const QString &option, const QVariant &value)
{
bool ok = false;
if (option == QuillImageFilter::Radius) {
double radius = value.toDouble(&ok);
if (ok) {
m_Radius = radius;
}
} else if (option == QuillImageFilter::Center) {
QPoint center = value.toPoint();
if (!center.isNull()) {
m_Center = center;
ok = true;
}
} else if (option == FORCE_OPTION) {
double force = value.toDouble(&ok);
ok = ok && force <= 1.0 && force >= -1.0;
if (ok) {
// Divide by the FORCE_FACTOR to get appropiated values for
// the Amplitude used by the "distort" function
m_Force = force/FORCE_FACTOR;
}
}
return ok;
}
示例5: PackValue
QString CSpmXml::PackValue(const QVariant& vtValue)
{
QString strValue;
switch (vtValue.type())
{
case QVariant::Size:
{
QSize size = vtValue.toSize();
strValue.sprintf(":%s:%d:%d", vtValue.typeName(), size.width(), size.height());
}
break;
case QVariant::Point:
{
QPoint pt = vtValue.toPoint();
strValue.sprintf(":%s:%d:%d", vtValue.typeName(), pt.x(), pt.y());
}
break;
default:
strValue = vtValue.toString();
break;
};
return strValue;
}
示例6: itemChange
QVariant GraphicsComponent::itemChange(GraphicsItemChange change, const QVariant &value)
{
switch (change)
{
case ItemPositionChange:
{
emit itemMoved(this);
QPoint pos = value.toPoint();
if (this->parent->getSnapToGrid()){
pos = this->calculateSnap(pos);
this->setProperty("x", pos.x());
this->setProperty("y", pos.y());
return QGraphicsItem::itemChange(change, QVariant(pos));
}
this->setProperty("x", this->x());
this->setProperty("y", this->y());
}
break;
case ItemSelectedChange:
break;
default:
break;
}
return QGraphicsItem::itemChange(change, value);
}
示例7: displayText
QString PointDelegate::displayText( const QVariant& value ) const
{
const QPoint p(value.toPoint());
return QString::fromLatin1(POINTEDIT_MASK)
.arg(p.x())
.arg(p.y());
}
示例8: write
QString write(const QVariant &variant)
{
if (!variant.isValid()) {
qWarning() << "Trying to serialize invalid QVariant";
return QString();
}
QString value;
switch (variant.type()) {
case QMetaType::QPoint:
{
QPoint p = variant.toPoint();
value = QString("%1,%2").arg(QString::number(p.x()), QString::number(p.y()));
break;
}
case QMetaType::QPointF:
{
QPointF p = variant.toPointF();
value = QString("%1,%2").arg(QString::number(p.x(), 'f'), QString::number(p.y(), 'f'));
break;
}
case QMetaType::QSize:
{
QSize s = variant.toSize();
value = QString("%1x%2").arg(QString::number(s.width()), QString::number(s.height()));
break;
}
case QMetaType::QSizeF:
{
QSizeF s = variant.toSizeF();
value = QString("%1x%2").arg(QString::number(s.width(), 'f'), QString::number(s.height(), 'f'));
break;
}
case QMetaType::QRect:
{
QRect r = variant.toRect();
value = QString("%1,%2,%3x%4").arg(QString::number(r.x()), QString::number(r.y()),
QString::number(r.width()), QString::number(r.height()));
break;
}
case QMetaType::QRectF:
{
QRectF r = variant.toRectF();
value = QString("%1,%2,%3x%4").arg(QString::number(r.x(), 'f'), QString::number(r.y(), 'f'),
QString::number(r.width(), 'f'), QString::number(r.height(), 'f'));
break;
}
default:
QVariant strVariant = variant;
strVariant.convert(QVariant::String);
if (!strVariant.isValid())
qWarning() << Q_FUNC_INFO << "cannot serialize type " << QMetaType::typeName(variant.type());
value = strVariant.toString();
}
return value;
}
示例9: SetupUi
void MainWindow::SetupUi()
{
resize(600, 400);
//set the main toolbar
mainToolbar = new QToolBar();
mainToolbar->setEnabled(true);
mainToolbar->setIconSize(QSize(16, 16));
addToolBar(Qt::TopToolBarArea, mainToolbar);
newAction = new QAction(QIcon(":/Resources/images/new.png"), tr("&New"), this);
connect(newAction, SIGNAL(triggered()), this, SLOT(OnNew()));
mainToolbar->addAction(newAction);
openAction = new QAction(QIcon(":/Resources/images/open.png"), tr("&Open"), this);
openAction->setShortcut(QKeySequence::Open);
connect(openAction, SIGNAL(triggered()), this, SLOT(OnOpen()));
mainToolbar->addAction(openAction);
saveAction = new QAction(QIcon(":/Resources/images/save.png"), tr("&Save"), this);
saveAction->setShortcut(QKeySequence::Save);
connect(saveAction, SIGNAL(triggered()), this, SLOT(OnSave()));
mainToolbar->addAction(saveAction);
undoAction = new QAction(QIcon(":/Resources/images/undo.png"), tr("&Undo"), this);
undoAction->setShortcut(QKeySequence::Undo);
connect(undoAction, SIGNAL(triggered()), this, SLOT(OnUndo()));
mainToolbar->addAction(undoAction);
redoAction = new QAction(QIcon(":/Resources/images/redo.png"), tr("&Redo"), this);
redoAction->setShortcut(QKeySequence::Redo);
connect(redoAction, SIGNAL(triggered()), this, SLOT(OnRedo()));
mainToolbar->addAction(redoAction);
setWindowTitle(QApplication::translate("Natural Calculator", "Natural Calculator", 0, QApplication::UnicodeUTF8));
QMetaObject::connectSlotsByName(this);
QVariant p = settings.Load("NaturalCalculator", "position");
move(p.toPoint());
p = settings.Load("NaturalCalculator", "size");
resize(p.toSize());
//set the main window
formulaWnd = new FormulaWnd(this);
formulaWnd->setObjectName(QString::fromUtf8("formulaWnd"));
formulaWnd->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred);
QWidget* c = new QWidget();
QBoxLayout* layout = new QBoxLayout(QBoxLayout::LeftToRight);
layout->addWidget(formulaWnd);
c->setLayout(layout);
setCentralWidget(c);
}
示例10: WriteAttributes
static void WriteAttributes(QObject* obj,QDomElement& el,QDomDocument& doc) {
el.setAttribute("type",obj->metaObject()->className());
for(int i = 0; i < obj->metaObject()->propertyCount(); ++i) {
QMetaProperty metaProperty(obj->metaObject()->property(i));
{
QDomElement prop = doc.createElement("property");
prop.setAttribute("name",QString(metaProperty.name()));
QVariant value = metaProperty.read(obj);
QString strValue;
if (metaProperty.type()==QVariant::String) {
strValue = value.toString();
} else if (metaProperty.type()==QVariant::Int) {
strValue = value.toString();
} else if (metaProperty.type()==QVariant::UInt) {
strValue = value.toString();
} else if (metaProperty.type()==QVariant::Double) {
strValue = value.toString();
} else if (metaProperty.type()==QVariant::Bool) {
strValue = value.toBool() ? "1" : "0";
} else if (metaProperty.type()==QVariant::Point) {
strValue = QString::number(value.toPoint().x())+";"
+ QString::number(value.toPoint().y());
} else if (metaProperty.type()==QVariant::PointF) {
strValue = QString::number(value.toPointF().x())+";"
+ QString::number(value.toPointF().y());
} else if (metaProperty.type()==QVariant::Size) {
strValue = QString::number(value.toSize().width())+";"
+ QString::number(value.toSize().height());
} else if (metaProperty.type()==QVariant::SizeF) {
strValue = QString::number(value.toSizeF().width())+";"
+ QString::number(value.toSizeF().height());
} else {
QByteArray ar;
QDataStream ds(&ar,QIODevice::WriteOnly);
ds << value;
strValue = ar.toBase64().data();
}
prop.setAttribute("value",strValue);
el.appendChild(prop);
}
}
}
示例11: showEvent
void Window::showEvent(QShowEvent* event) {
resizeFrame(m_screenWidget->sizeHint().width(), m_screenWidget->sizeHint().height());
QVariant windowPos = m_config->getQtOption("windowPos");
if (!windowPos.isNull()) {
move(windowPos.toPoint());
} else {
QRect rect = frameGeometry();
rect.moveCenter(QApplication::desktop()->availableGeometry().center());
move(rect.topLeft());
}
}
示例12: displayText
QString VariantDelegate::displayText(const QVariant &value)
{
switch (value.type()) {
case QVariant::Bool:
case QVariant::ByteArray:
case QVariant::Char:
case QVariant::Double:
case QVariant::Int:
case QVariant::LongLong:
case QVariant::String:
case QVariant::UInt:
case QVariant::ULongLong:
return value.toString();
case QVariant::Color:
{
QColor color = qvariant_cast<QColor>(value);
return QString("(%1,%2,%3,%4)")
.arg(color.red()).arg(color.green())
.arg(color.blue()).arg(color.alpha());
}
case QVariant::Date:
return value.toDate().toString(Qt::ISODate);
case QVariant::DateTime:
return value.toDateTime().toString(Qt::ISODate);
case QVariant::Invalid:
return "<Invalid>";
case QVariant::Point:
{
QPoint point = value.toPoint();
return QString("(%1,%2)").arg(point.x()).arg(point.y());
}
case QVariant::Rect:
{
QRect rect = value.toRect();
return QString("(%1,%2,%3,%4)")
.arg(rect.x()).arg(rect.y())
.arg(rect.width()).arg(rect.height());
}
case QVariant::Size:
{
QSize size = value.toSize();
return QString("(%1,%2)").arg(size.width()).arg(size.height());
}
case QVariant::StringList:
return value.toStringList().join(',');
case QVariant::Time:
return value.toTime().toString(Qt::ISODate);
default:
break;
}
return QString("<%1>").arg(value.typeName());
}
示例13: loadItemPositions
void DesktopWindow::loadItemPositions() {
// load custom item positions
customItemPos_.clear();
Settings& settings = static_cast<Application*>(qApp)->settings();
QString configFile = QString("%1/desktop-items-%2.conf").arg(settings.profileDir(settings.profileName())).arg(screenNum_);
QSettings file(configFile, QSettings::IniFormat);
auto delegate = static_cast<Fm::FolderItemDelegate*>(listView_->itemDelegateForColumn(0));
auto grid = delegate->itemSize();
QRect workArea = qApp->desktop()->availableGeometry(screenNum_);
workArea.adjust(12, 12, -12, -12);
char* dektopPath = Fm::Path::getDesktop().toStr();
QString desktopDir = QString(dektopPath) + QString("/");
g_free(dektopPath);
std::vector<QPoint> usedPos;
for(auto& item: customItemPos_) {
usedPos.push_back(item.second);
}
// FIXME: this is inefficient
Q_FOREACH(const QString& name, file.childGroups()) {
if(!QFile::exists(desktopDir + name.toUtf8())) {
// the file may have been removed from outside LXQT
continue;
}
file.beginGroup(name);
QVariant var = file.value("pos");
if(var.isValid()) {
QPoint customPos = var.toPoint();
if(customPos.x() >= workArea.x() && customPos.y() >= workArea.y()
&& customPos.x() + grid.width() <= workArea.right() + 1
&& customPos.y() + grid.height() <= workArea.bottom() + 1) {
// correct positions that are't aligned to the grid
alignToGrid(customPos, workArea.topLeft(), grid, listView_->spacing());
// FIXME: this is very inefficient
while(std::find(usedPos.cbegin(), usedPos.cend(), customPos) != usedPos.cend()) {
customPos.setY(customPos.y() + grid.height() + listView_->spacing());
if(customPos.y() + grid.height() > workArea.bottom() + 1) {
customPos.setX(customPos.x() + grid.width() + listView_->spacing());
customPos.setY(workArea.top());
}
}
customItemPos_[name.toStdString()] = customPos;
usedPos.push_back(customPos);
}
}
file.endGroup();
}
}
示例14: setOption
bool RedEyeDetection::setOption(const QString &option, const QVariant &value)
{
bool bOk = true;
if (option == QuillImageFilter::Center)
priv->center = value.toPoint();
else if (option == QuillImageFilter::Radius)
priv->eyeRadius = value.toInt(&bOk);
else if (option == QuillImageFilter::Tolerance)
priv->tapErrorTolerance = value.toInt(&bOk);
else
bOk = false;
return bOk;
}
示例15: setOption
bool TiltShift::setOption(const QString& filterOption, const QVariant& value)
{
bool result = true;
if (filterOption == QuillImageFilter::Radius) {
m_radius = value.toInt();
} else if (filterOption == QuillImageFilter::Horizontal) {
m_horizontalEffect = value.toBool();
} else if (filterOption == QuillImageFilter::Center) {
m_focusPoint = value.toPoint();
} else {
result = false;
}
return result;
}