Luc4
12th April 2010, 15:09
Hi! I created a property in a subclass of QGraphicsProxyWidget this way:
class SlideshowItemProxyWidget : public QGraphicsProxyWidget {
Q_OBJECT
Q_PROPERTY(QPointF center READ center WRITE setCenter)
public:
SlideshowItemProxyWidget(QGraphicsItem* parent);
QPointF center();
void setCenter(QPointF point);
};
SlideshowItemProxyWidget::SlideshowItemProxyWidget (QGraphicsItem* parent) : QGraphicsProxyWidget(parent) {
}
QPointF SlideshowItemProxyWidget::center() {
return QPointF(pos().x() + size().width()/2, pos().y() + size().height()/2);
}
void SlideshowItemProxyWidget::setCenter(QPointF point) {
setPos(point.x() - size().width(), point.y() - size().height());
}
It seems to work correctly when called. The problem is that it seems it's not called when creating an animation with QPropertyAnimation this way:
imageItem = (SlideshowItemProxyWidget*)this->addWidget(labelPixmap);
QPropertyAnimation* animNewImage = new QPropertyAnimation(imageItem, "center");
animNewImage->setDuration(IMAGE_TRANSITION_INTERVAL);
animNewImage->setStartValue(QPointF(1000, 0));
animNewImage->setEndValue(view->mapToScene(QPointF((view->width() - imageItem->boundingRect().width()*currentScale)/2,
(view->height() - imageItem->boundingRect().height()*currentScale)/2).toPoint()));
connect(animNewImage, SIGNAL(finished()), this, SLOT(adaptForNewImage()));
animNewImage->start(QPropertyAnimation::DeleteWhenStopped);
I placed a breakpoint in the method and it doesn't stop there in this case. Nothing happens indeed. Any idea why?
Thanks for any help!
class SlideshowItemProxyWidget : public QGraphicsProxyWidget {
Q_OBJECT
Q_PROPERTY(QPointF center READ center WRITE setCenter)
public:
SlideshowItemProxyWidget(QGraphicsItem* parent);
QPointF center();
void setCenter(QPointF point);
};
SlideshowItemProxyWidget::SlideshowItemProxyWidget (QGraphicsItem* parent) : QGraphicsProxyWidget(parent) {
}
QPointF SlideshowItemProxyWidget::center() {
return QPointF(pos().x() + size().width()/2, pos().y() + size().height()/2);
}
void SlideshowItemProxyWidget::setCenter(QPointF point) {
setPos(point.x() - size().width(), point.y() - size().height());
}
It seems to work correctly when called. The problem is that it seems it's not called when creating an animation with QPropertyAnimation this way:
imageItem = (SlideshowItemProxyWidget*)this->addWidget(labelPixmap);
QPropertyAnimation* animNewImage = new QPropertyAnimation(imageItem, "center");
animNewImage->setDuration(IMAGE_TRANSITION_INTERVAL);
animNewImage->setStartValue(QPointF(1000, 0));
animNewImage->setEndValue(view->mapToScene(QPointF((view->width() - imageItem->boundingRect().width()*currentScale)/2,
(view->height() - imageItem->boundingRect().height()*currentScale)/2).toPoint()));
connect(animNewImage, SIGNAL(finished()), this, SLOT(adaptForNewImage()));
animNewImage->start(QPropertyAnimation::DeleteWhenStopped);
I placed a breakpoint in the method and it doesn't stop there in this case. Nothing happens indeed. Any idea why?
Thanks for any help!