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. [Solved]QSplitter Animation
Forum Updated to NodeBB v4.3 + New Features

[Solved]QSplitter Animation

Scheduled Pinned Locked Moved General and Desktop
13 Posts 3 Posters 6.2k 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.
  • raven-worxR Offline
    raven-worxR Offline
    raven-worx
    Moderators
    wrote on last edited by
    #2

    [quote author="Saki" date="1372316713"]Now I'd like to show the hide one by expand that widget, I have tried QPropertyAnimation, but nothing happened. Could anyone help me with the problem?[/quote]
    Not with the information provided...

    Please post the code for your property animation and your class which you want to animate.

    --- 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
    • S Offline
      S Offline
      Saki
      wrote on last edited by
      #3

      [quote author="raven-worx" date="1372317644"][quote author="Saki" date="1372316713"]Now I'd like to show the hide one by expand that widget, I have tried QPropertyAnimation, but nothing happened. Could anyone help me with the problem?[/quote]
      Not with the information provided...

      Please post the code for your property animation and your class which you want to animate.

      [/quote]

      I'm so sorry I forget it...Here is my code:

      @kcicompiledock::kcicompiledock(QWidget *parent):
      QDockWidget(parent)
      {
      //Set Object Name.
      setObjectName(QString("Compile Dock"));

      //Set Dock Style.
      setContentsMargins(0,0,0,0);
      QPalette pal=this->palette();
      //pal.setColor(QPalette::Base,QColor(0x35,0x35,0x35));
      pal.setColor(QPalette::Base,QColor(0x35,0x35,0x35));
      pal.setColor(QPalette::WindowText,QColor(255,255,255));
      pal.setColor(QPalette::Button,QColor(83,83,83));
      pal.setColor(QPalette::Text,QColor(255,255,255));
      pal.setColor(QPalette::ButtonText,QColor(255,255,255));
      this->setPalette(pal);
      setWindowTitle(QString(tr("Compiler")));
      setAllowedAreas(Qt::BottomDockWidgetArea);
      
      //Set Dock Widget and Layout.
      //objCombine=new QWidget(this);
      //objCombine->setContentsMargins(0,0,0,0);
      splCombine=new QSplitter(Qt::Horizontal, this);
      splCombine->setContentsMargins(0,0,0,0);
      
      //Set Text Output.
      compileOutput=new QPlainTextEdit(this);
      compileOutput->setContentsMargins(0,0,0,0);
      compileOutput->setWordWrapMode(QTextOption::NoWrap);
      splCombine->addWidget(compileOutput);
      
      //Set TreeView Controls.
      trevwCompileInfo=new QTreeView(this);
      trevwCompileInfo->setContentsMargins(0,0,0,0);
      pal=trevwCompileInfo->palette();
      pal.setColor(QPalette::Foreground,QColor(255,255,255));
      trevwCompileInfo->setPalette(pal);
      compileInfo=new QStandardItemModel();
      trevwCompileInfo->setGeometry(0,0,0,0);
      splCombine->addWidget(trevwCompileInfo);
      QList<int> l_sizes;
      l_sizes << width() << 0;
      splCombine->setSizes(l_sizes);
      
      setWidget(splCombine);
      

      }

      void kcicompiledock::animeShowError()
      {
      QPropertyAnimation showTrevwAnime(trevwCompileInfo,"geometry");
      QRect startRect=trevwCompileInfo->rect();
      QRect finalRect=startRect;
      finalRect.setWidth(100);
      showTrevwAnime.setStartValue(startRect);
      showTrevwAnime.setEndValue(finalRect);

      showTrevwAnime.start();
      

      }@

      I'd like to animate the QTreeView object, like the code in animeShowError. But I know this code didn't work at all. I don't know how to animate the widget.

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

        i don't see any QPropertyAnimation in your code?!

        --- 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
        • S Offline
          S Offline
          Saki
          wrote on last edited by
          #5

          [quote author="raven-worx" date="1372326854"]i don't see any QPropertyAnimation in your code?![/quote]

          Please see LINE #50.

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

            your animation doesn't work because you create the animation object on the stack...thus it is destroyed right after the method is exited.

            so you should do this instead:
            @
            void kcicompiledock::animeShowError()
            {
            QPropertyAnimation* showTrevwAnime = new QPropertyAnimation(trevwCompileInfo,"geometry");
            QRect startRect=trevwCompileInfo->rect();
            QRect finalRect=startRect;
            finalRect.setWidth(100);
            showTrevwAnime->setStartValue(startRect);
            showTrevwAnime->setEndValue(finalRect);

            showTrevwAnime->start(QAbstractAnimation::DeleteWhenStopped);
            

            }
            @

            --- 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
            • S Offline
              S Offline
              Saki
              wrote on last edited by
              #7

              [quote author="raven-worx" date="1372348188"]your animation doesn't work because you create the animation object on the stack...thus it is destroyed right after the method is exited.

              so you should do this instead:
              @
              void kcicompiledock::animeShowError()
              {
              QPropertyAnimation* showTrevwAnime = new QPropertyAnimation(trevwCompileInfo,"geometry");
              QRect startRect=trevwCompileInfo->rect();
              QRect finalRect=startRect;
              finalRect.setWidth(100);
              showTrevwAnime->setStartValue(startRect);
              showTrevwAnime->setEndValue(finalRect);

              showTrevwAnime->start(QAbstractAnimation::DeleteWhenStopped);
              

              }
              @[/quote]

              Thanks, but...is this the reason?! I can't believe it! I think I should change the object to the Parent Object(DockWidget), and change the property "geometry" into another. I'll try the code later.
              BTW: I'd like to know more about your code. Mine is just let the TreeView invisible. Why just destroy it when it stop will work? Shouldn't we change the size of one of the part of the dock?

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

                sure thats the reason... the animation can only work when there is a object which controls the animation. When the animation object is destroyed there is no animation.
                The DeleteWhenStopped argument is necessary to avoid memory leaks, since you don't hold a reference anywhere to delete it once it is finished.

                --- 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
                • S Offline
                  S Offline
                  Saki
                  wrote on last edited by
                  #9

                  [quote author="raven-worx" date="1372400678"]sure thats the reason... the animation can only work when there is a object which controls the animation. When the animation object is destroyed there is no animation.
                  The DeleteWhenStopped argument is necessary to avoid memory leaks, since you don't hold a reference anywhere to delete it once it is finished.[/quote]

                  I'm so sorry that this didn't work. I think that we shouldn't just change the geometry of TreeView. We should change the width of Dock's child window instead.

                  1 Reply Last reply
                  0
                  • S Offline
                    S Offline
                    Saki
                    wrote on last edited by
                    #10

                    Well, no one knows anything about this?

                    1 Reply Last reply
                    0
                    • S Offline
                      S Offline
                      Saki
                      wrote on last edited by
                      #11

                      All Right, It seems that I have to solve this problem by myself. Thanks for everyone.

                      1 Reply Last reply
                      0
                      • A Offline
                        A Offline
                        alizadeh91
                        wrote on last edited by
                        #12

                        Hi, For animating QSplitter you have to have a animation on a property of QSplitter not on property of its child widgets. so as the QSplitter has no property for sizes so you have to create that property by yourself and animate through it. (Try it to change splitter position without animation at first and then add animation on that property)

                        1 Reply Last reply
                        0
                        • S Offline
                          S Offline
                          Saki
                          wrote on last edited by
                          #13

                          [quote author="Mostafa Alizadeh" date="1374577477"]Hi, For animating QSplitter you have to have a animation on a property of QSplitter not on property of its child widgets. so as the QSplitter has no property for sizes so you have to create that property by yourself and animate through it. (Try it to change splitter position without animation at first and then add animation on that property)[/quote]

                          Thanks a million, and I solved it by using QTimeLine. This is not relate to the DeleteWhenStopped, right?

                          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