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. QPropertyAnimation problem: Variable widget height (upwards)
Forum Updated to NodeBB v4.3 + New Features

QPropertyAnimation problem: Variable widget height (upwards)

Scheduled Pinned Locked Moved General and Desktop
3 Posts 2 Posters 3.4k Views 1 Watching
  • 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.
  • D Offline
    D Offline
    ddonate
    wrote on last edited by
    #1

    Hi,

    I am trying to do a QPropertyAnimation but faced some problems.

    My target is a main widget with 2 parts: bottom & top, with no spacing between them.

    Bottom: fixed size
    Top: same width as bottom and animated height but UPWARDS (from 0px, i.e, initially "hidden"). Like a 'popup'

    Animation will start with a button:
    1st click: Top widget "goes up" from 0px to 100px in top of bottom widget
    2nd click: Top widget" goes down" from 100px to 0px in top of bottom widget ("hidden" again)

    I have tried using 'height' property, but no success since top widget increased its height downwards

    I have tried using 'geometry' property, using negative values since top widget position is referenced to its parent (main widget). This way my top widget go upwards (ok), but main widget does NOT resize, so top widget is NOT seen... I thought I could use 'valueChanged' signal from QPropertyAnimation (top widget height values: 0 -> 100) to change main widget geometry, but no success.

    I hope I have explained my problem...

    Any idea? Thanks in advance,

    Diego

    1 Reply Last reply
    0
    • raven-worxR Offline
      raven-worxR Offline
      raven-worx
      Moderators
      wrote on last edited by
      #2

      [quote author="ddonate" date="1387547070"]
      I hope I have explained my problem...
      [/quote]
      yes, but i hardly got you :)
      Please show some code anyway.

      --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
      If you have a question please use the forum so others can benefit from the solution in the future

      1 Reply Last reply
      0
      • D Offline
        D Offline
        ddonate
        wrote on last edited by
        #3

        Hi,

        Thanks for your response.

        Last code I have tried is:

        @// TOP FIXED WIDGET ------------------------------------
        QLabel* pLabelFixed = new QLabel( "fixed" );
        pLabelFixed->setFixedHeight( 50 );
        pLabelFixed->setFixedWidth(500);
        pLabelFixed->setFrameStyle( QFrame::StyledPanel );

        // BOTTOM VARIABLE -------------------------------------
        QLabel* pLabelVariable = new QLabel( "variable" );
        pLabelVariable->setFrameStyle( QFrame::StyledPanel );
        pLabelVariable->resize(500, 0);

        // WHOLE WIDGET ---------------------------------------
        QWidget* pWidget = new QWidget( NULL, Qt::Popup );
        pWidget->setFixedWidth( 500 );

        QVBoxLayout* pLayout = new QVBoxLayout();
        pLayout->setMargin(0);
        pLayout->setSpacing(0);

        pLayout->addWidget(pLabelVariable);
        pLayout->addWidget(pLabelFixed);
        pWidget->setLayout(pLayout);

        QPoint pos( 500,500 );
        pWidget->move( pos );
        pWidget->show();

        // ANIMATIONS ------------------------------------------
        QPropertyAnimation* pAni = new QPropertyAnimation( pLabelVariable, "minimumHeight" );
        pAni->setStartValue( 0 );
        pAni->setEndValue( 50 );
        pAni->setDuration( 1000 );
        pAni->start();

        QPropertyAnimation* pAni2 = new QPropertyAnimation( pWidget, "geometry" );
        pAni2->setStartValue( QRect( QPoint(500,500), QSize(500,50) ) );
        pAni2->setEndValue( QRect( QPoint(500,450), QSize(500,100) ) );
        pAni2->setDuration( 1000 );
        pAni2->start();@

        and the effect is what i need... BUT the mixed animation flickers too much. I think it is logic, since 1st animation makes TopWidget to downwards, while 2nd animation forces the whole widget to move upwards. It seems to cause "painting problems"...

        Any idea or another solution?

        Thanks in advance,

        Diego

        1 Reply Last reply
        0

        • Login

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