Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. QPushButton becomes invisible on hover event - opacity animation
Qt 6.11 is out! See what's new in the release blog

QPushButton becomes invisible on hover event - opacity animation

Scheduled Pinned Locked Moved Solved General and Desktop
1 Posts 1 Posters 655 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • SamurayHS Offline
    SamurayHS Offline
    SamurayH
    wrote on last edited by
    #1

    Hey everyone,
    This is the solution that worked for me while facing a mysterious issue (bug) today, hope it helps someone.
    I have a QWidget (subclass) with some QPushButtons in it (without layout). This widget is shown if it's hovered, and an opacity animation accompanies the display. And when it's shown you can press (or whatever...) the QPushButtons we have already talked about.
    Here is a code snippet:

    void widget::OpaShow
    {
          QGraphicsOpacityEffect *opacity = new QGraphicsOpacityEffect;
          setGraphicsEffect(opacity);
          QPropertyAnimation *anim = new QPropertyAnimation( opacity, "opacity" );
    
          anim->setDuration(500);
          anim->setStartValue(0.0);
          anim->setEndValue(1.0);
          anim->setEasingCurve(QEasingCurve::OutSine);
    }
    

    The problem occurred with msvc2015 compiler, (mingw is an easy guy). The QPushButtons inside my widget becomes invisible when I hover them, voilà :
    0_1531066209125_false.gif

    I still don't know why is that happening, it's a kind of bug I think.
    So the solution is to call deleteLater() for QGraphicsOpacityEffect object created, by adding this line to widget::OpaShow :

       connect(anim, SIGNAL(finished()), opacity, SLOT(deleteLater()));
    

    So the rendering will work as expected, and like it worked already on mingw
    0_1531066545521_true.gif

    Have a nice day :)

    "قال رسول الله صلى الله عليه وسلم : " أحب الناس إلى الله أنفعهم للناس

    1 Reply Last reply
    1

    • Login

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Get Qt Extensions
    • Unsolved