Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Solved QPushButton becomes invisible on hover event - opacity animation

    General and Desktop
    1
    1
    222
    Loading More Posts
    • 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.
    • SamurayH
      SamurayH last edited by

      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 Reply Quote 1
      • First post
        Last post