Results 1 to 3 of 3

Thread: Problems animating QGraphicsProxyWidget

  1. #1
    Join Date
    Mar 2006
    Posts
    56
    Thanks
    7
    Thanked 3 Times in 2 Posts
    Qt products
    Qt3 Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Problems animating QGraphicsProxyWidget

    Hi All,

    I'm trying to animate a push button I have in my scene.
    I want the button to become visible with an animation when the mouse enters the scene (essentially gradually changing the opacity of the button from 0 to 1)

    The QPropertyAnimation class seems to be exactly what I need but it is not working with QGraphicsProxyWidget.
    This is the way I'm creating the button when I initialize the interface of the QGraphicsView

    Qt Code:
    1. void MyQGraphicsView::buildInterface(){
    2. ....
    3. myButton = new QPushButton(this); // myButton member QPushButton variable
    4. myButtonProxy = scene()->addWidget(myButton); // myButtonProxy member QGraphicsProxyWidget variable
    5. ...
    6. }
    7.  
    8. void MyQGraphicsView::enterEvent( QEvent * )
    9. {
    10. QPropertyAnimation *animation = new QPropertyAnimation(myButtonProxy, "opacity");
    11. animation->setDuration(1000);
    12.  
    13. animation->setStartValue(0);
    14. animation->setEndValue(1);
    15.  
    16. animation->start(QAbstractAnimation::DeleteWhenStopped);
    17. }
    To copy to clipboard, switch view to plain text mode 

    The animation has no effect on the opacity of the button. I also tried for test to modify with an animation the position of the button. Well If I create the QPropertyAnimation using the proxy widget then the animation is not working, if I create it using the button itsself then the animation is working (see example below)

    Qt Code:
    1. void MyQGraphicsView::enterEvent( QEvent * )
    2. {
    3. // QPropertyAnimation *animation = new QPropertyAnimation(myButtonProxy, "pos"); // DOES NOT WORK
    4. QPropertyAnimation *animation = new QPropertyAnimation(myButton, "pos");
    5. animation->setDuration(1000);
    6.  
    7. animation->setStartValue(QPointF(0,0));
    8. animation->setEndValue(QPointF(scene()->width()/2, scene()->height()/2));
    9.  
    10. animation->start(QAbstractAnimation::DeleteWhenStopped);
    11. }
    To copy to clipboard, switch view to plain text mode 

    I'm using Qt 4.7.3
    Do you have any idea how to fix this issue?

    Thanks in advance,
    Calogero
    Last edited by kalos80; 27th August 2012 at 11:50.

  2. #2
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    5,319
    Thanks
    316
    Thanked 870 Times in 857 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: Problems animating QGraphicsProxyWidget

    Try using the windowOpacity property of the QPushButton instead of the opacity property of the QGraphicsProxyWidget.
    <=== The Great Pumpkin says ===>
    Please use CODE tags when posting source code so it is more readable. Click "Go Advanced" and then the "#" icon to insert the tags. Paste your code between them.

  3. #3
    Join Date
    Mar 2006
    Posts
    56
    Thanks
    7
    Thanked 3 Times in 2 Posts
    Qt products
    Qt3 Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Problems animating QGraphicsProxyWidget

    d_stranz thanks for your reply.

    I already tried that property but it is not working. As far as I understand that property can only be used for top level widgets.


    Added after 1 41 minutes:


    I could fix the problem.
    I do not need to pass a parent to the QPushButton when creating it.
    Last edited by kalos80; 28th August 2012 at 10:49.

Similar Threads

  1. Animating a QwtPolarPlot
    By bwnicewo in forum Qwt
    Replies: 5
    Last Post: 14th June 2012, 15:38
  2. Animating a QwtPolarPlot
    By bwnicewo in forum Qt Programming
    Replies: 0
    Last Post: 8th June 2012, 17:54
  3. Animating QDockWidget
    By vajindarladdad in forum Newbie
    Replies: 1
    Last Post: 15th December 2008, 08:02
  4. animating a toolbar??!?
    By nupul in forum Qt Programming
    Replies: 4
    Last Post: 1st April 2006, 08:27

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
  •  
Qt is a trademark of The Qt Company.