wallacesoh
16th October 2013, 04:59
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!
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!