Hello!
I want QLabel, that contains image, make image bigger on enterEvent,
and smaller on leaveEvent. (animate it by QPropertyAnimation and QStateMachine ). For this purposes I subclassed QLabel, just like this:
{
Q_OBJECT
public:
~MyLabel();
protected slots:
virtual void enterEvent
( QEvent * event
);
virtual void leaveEvent
( QEvent * event
);
};
{
}
MyLabel::~MyLabel()
{
}
void MyLabel
::enterEvent ( QEvent * event
) {
}
void MyLabel
::leaveEvent ( QEvent * event
) {
}
class MyLabel : public QLabel
{
Q_OBJECT
public:
MyLabel(QWidget * parent = 0);
~MyLabel();
protected slots:
virtual void enterEvent ( QEvent * event );
virtual void leaveEvent ( QEvent * event );
};
MyLabel::MyLabel(QWidget * parent) : QWidget(parent)
{
}
MyLabel::~MyLabel()
{
}
void MyLabel::enterEvent ( QEvent * event )
{
}
void MyLabel::leaveEvent ( QEvent * event )
{
}
To copy to clipboard, switch view to plain text mode
But what next - have no idea...
Tried something like :
void MyLabel
::enterEvent ( QEvent * event
) {
QPropertyAnimation *animation = new QPropertyAnimation(this, "geometry");
animation->setDuration(600);
animation
->setStartValue
(QRect(this
->geometry
().
x(), this
->geometry
().
y(),
64,
64));
animation
->setEndValue
(QRect(this
->geometry
().
x(), this
->geometry
().
y(),
128,
128));
animation->start();
}
void MyLabel::enterEvent ( QEvent * event )
{
QPropertyAnimation *animation = new QPropertyAnimation(this, "geometry");
animation->setDuration(600);
animation->setStartValue(QRect(this->geometry().x(), this->geometry().y(), 64, 64));
animation->setEndValue(QRect(this->geometry().x(), this->geometry().y(), 128, 128));
animation->start();
}
To copy to clipboard, switch view to plain text mode
But that is not the idea, because this->geometry().x() returns 0....
Bookmarks