Results 1 to 3 of 3

Thread: Make image bigger, when the mouse is over QLabel

  1. #1
    Join Date
    Aug 2011
    Posts
    10
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Windows

    Question Make image bigger, when the mouse is over QLabel

    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:

    Qt Code:
    1. void MainWindow::label_hover()
    2. {
    3. QPropertyAnimation *animation = new QPropertyAnimation(ui->label, "geometry");
    4. animation->setDuration(600);
    5. animation->setStartValue(QRect(390,70, 64, 64));
    6. animation->setEndValue(QRect(390, 70, 128, 128));
    7. animation->setEasingCurve(QEasingCurve::OutCubic);
    8. animation->start();
    9. }
    To copy to clipboard, switch view to plain text mode 

  2. #2
    Join Date
    Aug 2011
    Location
    Seoul, Korea
    Posts
    46
    Thanks
    9
    Thanked 5 Times in 5 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Make image bigger, when the mouse is over QLabel

    Quote Originally Posted by Globulus View Post
    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:

    Qt Code:
    1. void MainWindow::label_hover()
    2. {
    3. QPropertyAnimation *animation = new QPropertyAnimation(ui->label, "geometry");
    4. animation->setDuration(600);
    5. animation->setStartValue(QRect(390,70, 64, 64));
    6. animation->setEndValue(QRect(390, 70, 128, 128));
    7. animation->setEasingCurve(QEasingCurve::OutCubic);
    8. animation->start();
    9. }
    To copy to clipboard, switch view to plain text mode 
    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

  3. #3
    Join Date
    Aug 2011
    Posts
    10
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Make image bigger, when the mouse is over QLabel

    Dong Back Kim, thanks for your help!

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

Similar Threads

  1. Replies: 6
    Last Post: 21st September 2009, 10:55
  2. How to make dropdown button bigger
    By Vadi in forum Qt Programming
    Replies: 1
    Last Post: 13th November 2008, 23:54
  3. Replies: 13
    Last Post: 18th February 2008, 00:20
  4. Replies: 7
    Last Post: 27th June 2007, 09:34

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.