本文整理汇总了C++中QEasingCurve::setType方法的典型用法代码示例。如果您正苦于以下问题:C++ QEasingCurve::setType方法的具体用法?C++ QEasingCurve::setType怎么用?C++ QEasingCurve::setType使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QEasingCurve
的用法示例。
在下文中一共展示了QEasingCurve::setType方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: operators
void tst_QEasingCurve::operators()
{
// operator=
QEasingCurve curve;
QEasingCurve curve2;
curve.setCustomType(&discreteEase);
curve2 = curve;
QCOMPARE(curve2.type(), QEasingCurve::Custom);
QCOMPARE(curve2.valueForProgress(0.0), 0.0);
QCOMPARE(curve2.valueForProgress(0.05), 0.0);
QCOMPARE(curve2.valueForProgress(0.15), 0.1);
QCOMPARE(curve2.valueForProgress(0.25), 0.2);
QCOMPARE(curve2.valueForProgress(0.35), 0.3);
QCOMPARE(curve2.valueForProgress(0.999999), 0.9);
// operator==
curve.setType(QEasingCurve::InBack);
curve2 = curve;
curve2.setOvershoot(qreal(1.70158f));
QCOMPARE(curve.overshoot(), curve2.overshoot());
QVERIFY(curve2 == curve);
curve.setOvershoot(3.0);
QVERIFY(curve2 != curve);
curve2.setOvershoot(3.0);
QVERIFY(curve2 == curve);
curve2.setType(QEasingCurve::Linear);
QCOMPARE(curve.overshoot(), curve2.overshoot());
QVERIFY(curve2 != curve);
curve2.setType(QEasingCurve::InBack);
QCOMPARE(curve.overshoot(), curve2.overshoot());
QVERIFY(curve2 == curve);
}
示例2: applyAnimation
slideShowEngine::AnimationState slideShowEngine::applyAnimation()
{
effect e;
QEasingCurve curve;
qreal currentValue;
Pixmap *item;
if(m_currentStep==EnterAnimation)
e=m_currentNode.enterEffect();
else
if(m_currentStep==DisplayAnimation)
e=m_currentNode.displayEffect();
else
if(m_currentStep==ExitAnimation)
e=m_currentNode.exitEffect();
int duration=e.duration();
//int elapsed=m_stepCurrentTime;
curve.setPeriod(duration);
qreal startVal=qreal(e.startValue());
qreal endVal=qreal(e.endValue());
curve.setType(e.easingCurve());
//qreal valore=qreal(m_stepCurrentTime*TIMER_ANIMATION);
qreal valore=qreal(m_stepCurrentTime);
//qreal valore=qreal(m_stepCurrentTime*10);
valore=valore/(qreal(duration));
//valore=valore/10;
//currentValue=curve.valueForProgress(valore);
currentValue=endVal+(1.0-curve.valueForProgress(valore))*(startVal-endVal);
item=m_PixmapList[m_currentSlideIndex];
if(e.effectType()=="pos")
item->setProperty(e.effectType().toLatin1(),QVariant(QPointF(currentValue,0)));
else
item->setProperty(e.effectType().toLatin1(),QVariant(currentValue));
//if(m_stepCurrentTime*TIMER_ANIMATION < e.duration()/**10*/)
if(m_stepCurrentTime < duration)
//if(m_stepCurrentTime*10 < e.duration()/**10*/)
return RunningAnimation;
else
return EndAnimation;
}
示例3: operators
void tst_QEasingCurve::operators()
{
// operator=
QEasingCurve curve;
QEasingCurve curve2;
curve.setCustomType(&discreteEase);
curve2 = curve;
QCOMPARE(curve2.type(), QEasingCurve::Custom);
QCOMPARE(curve2.valueForProgress(0.0), 0.0);
QCOMPARE(curve2.valueForProgress(0.05), 0.0);
QCOMPARE(curve2.valueForProgress(0.15), 0.1);
QCOMPARE(curve2.valueForProgress(0.25), 0.2);
QCOMPARE(curve2.valueForProgress(0.35), 0.3);
QCOMPARE(curve2.valueForProgress(0.999999), 0.9);
// operator==
curve.setType(QEasingCurve::InBack);
curve2 = curve;
curve2.setOvershoot(qreal(1.70158));
QCOMPARE(curve.overshoot(), curve2.overshoot());
QVERIFY(curve2 == curve);
curve.setOvershoot(3.0);
QVERIFY(curve2 != curve);
curve2.setOvershoot(3.0);
QVERIFY(curve2 == curve);
curve2.setType(QEasingCurve::Linear);
QCOMPARE(curve.overshoot(), curve2.overshoot());
QVERIFY(curve2 != curve);
curve2.setType(QEasingCurve::InBack);
QCOMPARE(curve.overshoot(), curve2.overshoot());
QVERIFY(curve2 == curve);
QEasingCurve curve3;
QEasingCurve curve4;
curve4.setAmplitude(curve4.amplitude());
QEasingCurve curve5;
curve5.setAmplitude(0.12345);
QVERIFY(curve3 == curve4); // default value and not assigned
QVERIFY(curve3 != curve5); // unassinged and other value
QVERIFY(curve4 != curve5);
}
示例4: spawnEnemies
void GameScene::spawnEnemies(GraphicsEnemyObject::EnemyType type, bool inverted)
{
QEasingCurve curve;
switch (type)
{
case GraphicsEnemyObject::EnemyType::White:
case GraphicsEnemyObject::EnemyType::Green:
curve.setType(static_cast<QEasingCurve::Type>(qrand() % 41));
break;
case GraphicsEnemyObject::EnemyType::Boss:
curve.setCustomType(&CustomEasingCurve::simpleEasingCurve);
break;
}
auto enemy = new GraphicsEnemyObject(type, curve, inverted);
addItem(enemy);
connect(enemy, &GraphicsEnemyObject::cannonTriggered, this,
&GameScene::planeShot);
connect(enemy, &GraphicsEnemyObject::exploded, this,
&GameScene::planeExploded);
}
示例5: setCustomType
void tst_QEasingCurve::setCustomType()
{
QEasingCurve curve;
curve.setCustomType(&discreteEase);
QCOMPARE(curve.type(), QEasingCurve::Custom);
QCOMPARE(curve.valueForProgress(0.0), 0.0);
QCOMPARE(curve.valueForProgress(0.05), 0.0);
QCOMPARE(curve.valueForProgress(0.10), 0.1);
QCOMPARE(curve.valueForProgress(0.15), 0.1);
QCOMPARE(curve.valueForProgress(0.20), 0.2);
QCOMPARE(curve.valueForProgress(0.25), 0.2);
QCOMPARE(curve.valueForProgress(0.30), 0.3);
QCOMPARE(curve.valueForProgress(0.35), 0.3);
QCOMPARE(curve.valueForProgress(0.999999), 0.9);
curve.setType(QEasingCurve::Linear);
QCOMPARE(curve.type(), QEasingCurve::Linear);
QCOMPARE(curve.valueForProgress(0.0), 0.0);
QCOMPARE(curve.valueForProgress(0.1), 0.1);
QCOMPARE(curve.valueForProgress(0.5), 0.5);
QCOMPARE(curve.valueForProgress(0.99), 0.99);
}
示例6: sipNoMethod
static PyObject *meth_QEasingCurve_setType(PyObject *sipSelf, PyObject *sipArgs)
{
PyObject *sipParseErr = NULL;
{
QEasingCurve::Type a0;
QEasingCurve *sipCpp;
if (sipParseArgs(&sipParseErr, sipArgs, "BE", &sipSelf, sipType_QEasingCurve, &sipCpp, sipType_QEasingCurve_Type, &a0))
{
sipCpp->setType(a0);
Py_INCREF(Py_None);
return Py_None;
}
}
/* Raise an exception if the arguments couldn't be parsed. */
sipNoMethod(sipParseErr, sipName_QEasingCurve, sipName_setType, doc_QEasingCurve_setType);
return NULL;
}
示例7: writeAttribute
//.........这里部分代码省略.........
} else {
qreal width = attributeToFloat(list.at(0), &conversionOK, WidthAttribute, orientation, &cacheOrientation);
qreal height = attributeToFloat(list.at(1), &conversionOK, HeightAttribute, orientation, &cacheOrientation);
return fillProperty(property, style, cacheOrientation, QSizeF(width, height));
}
}
} else if (attributeType == QMetaType::QPoint || attributeType == QMetaType::QPointF) {
//"point: 256px 123px;
//just split into pieces and create QPoint or QPointF depending on the attributeType
QList<QByteArray> list = valueString.split(' ');
list.removeAll("");
if (list.size() == 2) {
if (attributeType == QMetaType::QPoint) {
int x = attributeToInt(list.at(0), &conversionOK, WidthAttribute, orientation, &cacheOrientation);
int y = attributeToInt(list.at(1), &conversionOK, HeightAttribute, orientation, &cacheOrientation);
return fillProperty(property, style, cacheOrientation, QPoint(x, y));
} else {
qreal x = attributeToFloat(list.at(0), &conversionOK, WidthAttribute, orientation, &cacheOrientation);
qreal y = attributeToFloat(list.at(1), &conversionOK, HeightAttribute, orientation, &cacheOrientation);
return fillProperty(property, style, cacheOrientation, QPointF(x, y));
}
}
} else if (attributeType == QMetaType::QFont) {
QFont font = fontFromString(valueString, &conversionOK);
if (conversionOK) {
return fillProperty(property, style, cacheOrientation, font);
}
} else if (attributeType == QMetaType::QString) {
if (valueString.length() >= 2) {
if ((valueString.at(0) == 0x22) && (valueString.at(valueString.length()-1) == 0x22)) {
return fillProperty(property, style, cacheOrientation, QString(valueString.mid(1, valueString.length() - 2)));
}
} else if (valueString.length() == 0) {
return fillProperty(property, style, cacheOrientation, QString());
}
} else if (attributeType == QMetaType::QChar) {
if (valueString.length() == 3) {
if ((valueString.at(0) == '\'') && (valueString.at(2) == '\'')) {
return fillProperty(property, style, cacheOrientation, static_cast<QChar>(valueString.at(1)));
}
}
} else if (attributeType == qMetaTypeId<Qt::Alignment>()) {
if (DataTypeConverter.ALIGNMENTS.contains(valueString)) {
return fillProperty(property, style, cacheOrientation, qVariantFromValue(DataTypeConverter.ALIGNMENTS[valueString]));
}
} else if (attributeType == qMetaTypeId<Qt::Orientation>()) {
if (DataTypeConverter.ORIENTATIONS.contains(valueString)) {
return fillProperty(property, style, cacheOrientation, qVariantFromValue(DataTypeConverter.ORIENTATIONS[valueString]));
}
} else if (attributeType == qMetaTypeId<QTextCharFormat::UnderlineStyle>()) {
if (DataTypeConverter.UNDERLINESTYLES.contains(valueString)) {
return fillProperty(property, style, cacheOrientation, qVariantFromValue(DataTypeConverter.UNDERLINESTYLES[valueString]));
}
} else if (attributeType == qMetaTypeId<Qt::PenStyle>()) {
if (DataTypeConverter.PENSTYLES.contains(valueString)) {
return fillProperty(property, style, cacheOrientation, qVariantFromValue(DataTypeConverter.PENSTYLES[valueString]));
}
} else if (attributeType == qMetaTypeId<Qt::Axis>()) {
if (DataTypeConverter.AXES.contains(valueString)) {
return fillProperty(property, style, cacheOrientation, qVariantFromValue(DataTypeConverter.AXES[valueString]));
}
} else if (attributeType == qMetaTypeId<MFeedback>()) {
MFeedback feedback(valueString);
return fillProperty(property, style, cacheOrientation, qVariantFromValue(feedback));
} else if (attributeType == QMetaType::QEasingCurve) {
QEasingCurve curve;
// curve type
QList<QByteArray> list = valueString.split(',');
if (list.size() > 0) {
if (DataTypeConverter.EASINGCURVETYPES.contains(list.at(0))) {
int type = DataTypeConverter.EASINGCURVETYPES[list.at(0)];
if (type < FirstCustomType)
curve.setType(static_cast<QEasingCurve::Type>(type));
else if (type == OvershotBezier)
curve = MOvershotBezierEasingCurve();
// curve amplitude
if (list.size() > 1) {
curve.setAmplitude((qreal) list.at(1).toDouble());
// curve overshoot
if (list.size() > 2) {
curve.setOvershoot((qreal) list.at(2).toDouble());
// curve period
if (list.size() > 3) {
curve.setPeriod((qreal) list.at(3).toDouble());
}
}
}
return fillProperty(property, style, cacheOrientation, qVariantFromValue(curve));
}
}
} else if (attributeType == qMetaTypeId<QTextOption::WrapMode>()) {
if (DataTypeConverter.WRAPMODES.contains(valueString)) {
return fillProperty(property, style, cacheOrientation, qVariantFromValue(DataTypeConverter.WRAPMODES[valueString]));
}
}
MStyleSheetParser::outputParseError(MStyleSheetParser::stringCacheWithReverseLookup()->indexToString(filename), "Not a valid attribute(" + QLatin1String(property.typeName()) + "): " + MStyleSheetParser::stringCacheWithoutReverseLookup()->indexToString(name) + " : " + valueString, MStyleSheetParser::getLineNum(MStyleSheetParser::stringCacheWithReverseLookup()->indexToString(filename), position));
return false;
}