本文整理汇总了C++中QEasingCurve::setCustomType方法的典型用法代码示例。如果您正苦于以下问题:C++ QEasingCurve::setCustomType方法的具体用法?C++ QEasingCurve::setCustomType怎么用?C++ QEasingCurve::setCustomType使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QEasingCurve
的用法示例。
在下文中一共展示了QEasingCurve::setCustomType方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: animateItemRectVisible
void QtViewportInteractionEngine::animateItemRectVisible(const QRectF& itemRect)
{
ASSERT(m_scaleAnimation->state() == QAbstractAnimation::Stopped);
ASSERT(!scrollAnimationActive());
if (scrollAnimationActive())
return;
QRectF currentItemRectVisible = m_viewport->mapRectToWebContent(m_viewport->boundingRect());
if (itemRect == currentItemRectVisible)
return;
// FIXME: Investigate why that animation doesn't run when we are unfocused.
if (!m_viewport->isVisible() || !m_viewport->hasFocus()) {
// Apply the end result immediately when we are non-visible.
setItemRectVisible(itemRect);
return;
}
QEasingCurve easingCurve;
easingCurve.setCustomType(physicalOvershoot);
m_scaleAnimation->setDuration(kScaleAnimationDurationMillis);
m_scaleAnimation->setEasingCurve(easingCurve);
m_scaleAnimation->setStartValue(currentItemRectVisible);
m_scaleAnimation->setEndValue(itemRect);
m_scaleAnimation->start();
}
示例3: sipAddException
static PyObject *meth_QEasingCurve_setCustomType(PyObject *sipSelf, PyObject *sipArgs)
{
PyObject *sipParseErr = NULL;
{
PyObject * a0;
QEasingCurve *sipCpp;
if (sipParseArgs(&sipParseErr, sipArgs, "BF", &sipSelf, sipType_QEasingCurve, &sipCpp, &a0))
{
sipErrorState sipError = sipErrorNone;
#line 232 "C:\\Users\\marcus\\Downloads\\PyQt-gpl-5.4\\PyQt-gpl-5.4\\sip/QtCore/qeasingcurve.sip"
int i;
ec_custom_type *ct;
for (i = 0; i < ec_nr_custom_types; ++i)
{
ct = &ec_custom_types[i];
if (!ct->py_func || ct->py_func == a0)
break;
}
if (i == ec_nr_custom_types)
{
PyErr_Format(PyExc_ValueError, "a maximum of %d different easing functions are supported", ec_nr_custom_types);
sipError = sipErrorFail;
}
else
{
if (!ct->py_func)
{
ct->py_func = a0;
Py_INCREF(a0);
}
sipCpp->setCustomType(ct->func);
}
#line 401 "C:\\Users\\marcus\\Downloads\\PyQt-gpl-5.4\\PyQt-gpl-5.4\\QtCore/sipQtCoreQEasingCurve.cpp"
if (sipError == sipErrorFail)
return 0;
if (sipError == sipErrorNone)
{
Py_INCREF(Py_None);
return Py_None;
}
sipAddException(sipError, &sipParseErr);
}
}
/* Raise an exception if the arguments couldn't be parsed. */
sipNoMethod(sipParseErr, sipName_QEasingCurve, sipName_setCustomType, doc_QEasingCurve_setCustomType);
return NULL;
}
示例4: 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);
}
示例5: 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);
}
示例6: 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);
}