PDA

View Full Version : Make image bigger, when the mouse is over QLabel



Globulus
5th August 2011, 18:51
Hi, everyone!

So, how can I make QLabel widget,that contains image, save its centr,
when I change geometry.(just making image bigger, when the mouse is over QLabel
from 64x64 to 128x128)


Thanks for your help!

This is the code, that I use:



void MainWindow::label_hover()
{
QPropertyAnimation *animation = new QPropertyAnimation(ui->label, "geometry");
animation->setDuration(600);
animation->setStartValue(QRect(390,70, 64, 64));
animation->setEndValue(QRect(390, 70, 128, 128));
animation->setEasingCurve(QEasingCurve::OutCubic);
animation->start();
}

Dong Back Kim
6th August 2011, 00:36
Hi, everyone!

So, how can I make QLabel widget,that contains image, save its centr,
when I change geometry.(just making image bigger, when the mouse is over QLabel
from 64x64 to 128x128)


Thanks for your help!

This is the code, that I use:



void MainWindow::label_hover()
{
QPropertyAnimation *animation = new QPropertyAnimation(ui->label, "geometry");
animation->setDuration(600);
animation->setStartValue(QRect(390,70, 64, 64));
animation->setEndValue(QRect(390, 70, 128, 128));
animation->setEasingCurve(QEasingCurve::OutCubic);
animation->start();
}



Hi,

I would suggest having a extended class of QLabel and override mouse events (i.e. mouse enter and mouse leave) and override paint event for more advanced effects like gradually increasing or decreasing the size.

Regards,
Dong Back Kim

Globulus
6th August 2011, 10:39
Dong Back Kim, thanks for your help!

But, can you provide me with some code example???