Results 1 to 2 of 2

Thread: QPropertyAnimation Sliding Menu From Right Toolbar

  1. #1

    Default QPropertyAnimation Sliding Menu From Right Toolbar

    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.

    Qt Code:
    1. void ToolBarPalettes::openPalette()
    2. {
    3. if(openPaletteButton->isChecked())
    4. {
    5. paletteDlg->show();
    6. }
    7. else
    8. {
    9. paletteDlg->hide();
    10. }
    11. }
    To copy to clipboard, switch view to plain text mode 

    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.

    Qt Code:
    1. void ToolBarPalettes::openPalette()
    2. {
    3. if(openPaletteButton->isChecked())
    4. {
    5. QPropertyAnimation *animation = new QPropertyAnimation(paletteDlg, "geometry");
    6. animation->setDuration(3000);
    7. animation->setStartValue(QRect(-100, 50, paletteDlg->width(), paletteDlg->height()));
    8. animation->setEndValue(QRect(50, 50, paletteDlg->width(), paletteDlg->height()));
    9. animation->start();
    10. }
    11. else
    12. {
    13. QPropertyAnimation *animation = new QPropertyAnimation(paletteDlg, "geometry");
    14. animation->setDuration(3000);
    15. animation->setStartValue(QRect(50, 50, paletteDlg->width(), paletteDlg->height()));
    16. animation->setEndValue(QRect(-100, 50, paletteDlg->width(), paletteDlg->height()));
    17. animation->start();
    18. }
    19. }
    To copy to clipboard, switch view to plain text mode 

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

  2. #2
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: QPropertyAnimation Sliding Menu From Right Toolbar

    You will need to show() the dialog at least once., dialogs are created "hidden".

    If you hiding animation moves it so far off that it is not visible anymore, then you don't have to hide() it explicitly, but of course you can still do.

    Cheers,
    _

Similar Threads

  1. Replies: 1
    Last Post: 12th March 2012, 10:17
  2. Missing Icons for Menu and Toolbar
    By LostInTheWoods in forum Qt Tools
    Replies: 1
    Last Post: 8th January 2010, 11:42
  3. ToolBar Action With Menu
    By indifference in forum Qt Programming
    Replies: 4
    Last Post: 10th September 2007, 19:37
  4. Toolbar show menu
    By Michiel in forum Qt Programming
    Replies: 5
    Last Post: 26th May 2007, 15:22
  5. disable QMainWindow toolbar menu?
    By gfunk in forum Qt Programming
    Replies: 2
    Last Post: 10th January 2007, 18:24

Tags for this Thread

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
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.