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 Sliding Menu From Right Toolbar
Forum Updated to NodeBB v4.3 + New Features

QPropertyAnimation Sliding Menu From Right Toolbar

Scheduled Pinned Locked Moved General and Desktop
6 Posts 2 Posters 3.0k 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.
  • W Offline
    W Offline
    wallacesoh
    wrote on last edited by
    #1

    Hi. I am trying to do up a sliding dialog widget, which it will slide out from the right docked toolbar upon clicking on the tool button. Upon clicking on the tool button again, it will slide in back to the right docked toolbar.

    Previously, this is what I have done. Basically, I show() and hide() my dialog widget.

    @void ToolBarPalettes::openPalette()
    {
    if(openPaletteButton->isChecked())
    {
    paletteDlg->show();
    }
    else
    {
    paletteDlg->hide();
    }
    }@

    I tried to do the following to allow it to animate (slide out) from the toolbar. However, when I click on my tool button, nothing happens. The dialog widget did not slide out.

    @void ToolBarPalettes::openPalette()
    {
    if(openPaletteButton->isChecked())
    {
    QPropertyAnimation *animation = new QPropertyAnimation(paletteDlg, "geometry");
    animation->setDuration(3000);
    animation->setStartValue(QRect(-100, 50, paletteDlg->width(), paletteDlg->height()));
    animation->setEndValue(QRect(50, 50, paletteDlg->width(), paletteDlg->height()));
    animation->start();
    }
    else
    {
    QPropertyAnimation *animation = new QPropertyAnimation(paletteDlg, "geometry");
    animation->setDuration(3000);
    animation->setStartValue(QRect(50, 50, paletteDlg->width(), paletteDlg->height()));
    animation->setEndValue(QRect(-100, 50, paletteDlg->width(), paletteDlg->height()));
    animation->start();
    }
    }@

    Do I need to include the show() and hide() anywhere? Can anyone please help with this?
    Thanks!

    1 Reply Last reply
    0
    • p3c0P Offline
      p3c0P Offline
      p3c0
      Moderators
      wrote on last edited by
      #2

      Hi,

      Are you sure that your dialog is already visible before you start animation ?

      157

      1 Reply Last reply
      0
      • W Offline
        W Offline
        wallacesoh
        wrote on last edited by
        #3

        Yes. When I call paletteDlg->show() and paletteDlg->hide(), the dialog can be shown and hidden.

        1 Reply Last reply
        0
        • p3c0P Offline
          p3c0P Offline
          p3c0
          Moderators
          wrote on last edited by
          #4

          Yes indeed it can be, but my question is before you start the animation is paletteDlg already visible ?
          Or can you add paletteDlg->show() before
          @QPropertyAnimation *animation = new QPropertyAnimation(paletteDlg, "geometry");@
          which is in
          @
          if(openPaletteButton->isChecked())
          {}@
          and try if it works

          157

          1 Reply Last reply
          0
          • W Offline
            W Offline
            wallacesoh
            wrote on last edited by
            #5

            Thanks p3c0! I included paletteDlg->show() before (or even after)

            @animation->start();@

            And both methods work well. I thought with specifying the geometry coordinates of QRect, I do not need to specify show() or hide().

            1 Reply Last reply
            0
            • p3c0P Offline
              p3c0P Offline
              p3c0
              Moderators
              wrote on last edited by
              #6

              Yes even after will work as start() doesn't wait for animation to be finished but some frames may be invisible till that time.

              157

              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