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.
Code:
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.
Code:
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!
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,
_