Results 1 to 7 of 7

Thread: QLabel Text fade in/out

  1. #1
    Join Date
    Oct 2010
    Location
    Iran
    Posts
    27
    Thanks
    1
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11

    Question QLabel Text fade in/out

    Hi
    How to add fade in/out effect to QLabel Text ?

  2. #2
    Join Date
    Jan 2006
    Location
    Belgium
    Posts
    1,938
    Thanked 268 Times in 268 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows
    Wiki edits
    20

  3. #3
    Join Date
    Oct 2010
    Location
    Iran
    Posts
    27
    Thanks
    1
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11

    Default Re: QLabel Text fade in/out

    QLabel not propertyName Color or Opcity ?

  4. #4
    Join Date
    Jan 2006
    Location
    Belgium
    Posts
    1,938
    Thanked 268 Times in 268 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows
    Wiki edits
    20

    Default Re: QLabel Text fade in/out

    It has a font property, but that would not work too well with rich text in a label.
    And if you want another convenience property, you can easily add one.

  5. #5
    Join Date
    Oct 2010
    Location
    Iran
    Posts
    27
    Thanks
    1
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11

    Default Re: QLabel Text fade in/out

    ok!

    But need a property to use with QPropertyAnimation to create fade in/out animat
    Last edited by lamp; 30th November 2010 at 08:53.

  6. #6
    Join Date
    Jan 2006
    Location
    Belgium
    Posts
    1,938
    Thanked 268 Times in 268 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows
    Wiki edits
    20

    Default Re: QLabel Text fade in/out

    I guess you can look here too:
    http://doc.qt.nokia.com/qq/qq16-fader.html

    As for the property, the font property will work, but not for richt text.

  7. #7
    Join Date
    Oct 2016
    Posts
    2
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: QLabel Text fade in/out

    Qt Code:
    1. void MainWindow::on_pushButton_clicked()
    2. {
    3.  
    4. QGraphicsOpacityEffect *effect = new QGraphicsOpacityEffect();
    5. ui->label->setGraphicsEffect(effect);
    6. QPropertyAnimation *anim = new QPropertyAnimation(effect,"opacity");
    7. anim->setDuration(1000);
    8. anim->setStartValue(1.0);
    9. anim->setEndValue(0.0);
    10. anim->setEasingCurve(QEasingCurve::OutQuad);
    11. connect(anim, &QPropertyAnimation::finished, [=]()
    12. {
    13. ui->label->setText("gone");
    14. });
    15.  
    16. anim->start(QAbstractAnimation::DeleteWhenStopped);
    17. }
    To copy to clipboard, switch view to plain text mode 

    Hope this will help
    Last edited by anda_skoa; 6th October 2016 at 16:36. Reason: missing [code] tags

Similar Threads

  1. QLabel text and ElideMode (...)
    By Talei in forum Newbie
    Replies: 3
    Last Post: 8th May 2010, 18:54
  2. fade from one colour to another
    By panduro in forum Newbie
    Replies: 2
    Last Post: 18th June 2008, 13:30
  3. Position of text in a qlabel
    By jiveaxe in forum Qt Programming
    Replies: 1
    Last Post: 25th May 2008, 13:26
  4. How to right-justify QLabel text
    By JimDaniel in forum Qt Programming
    Replies: 2
    Last Post: 30th January 2008, 08:55
  5. Squeeze text in QLabel
    By jiveaxe in forum Qt Programming
    Replies: 5
    Last Post: 6th September 2007, 10:45

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.