MainWindow::MainWindow
{
[...]
//ui->widget->hide();//[1]
//ui->button->setChecked(false);//[2]
startgeometry
= QRect(0,
0,
0,
0);
connect(ui->button,SIGNAL(toggled(bool)),this,SLOT(togglePyShell(bool)));
}
void MainWindow::togglePyShell(bool show)
{
QRect formerGeometry
= QRect(ui
->widget
->geometry
());
if(startgeometry
==QRect(0,
0,
0,
0)){ startgeometry = formerGeometry;
}
if(show){
//ui->widget->show();//[3]
QPropertyAnimation *showAnimation = new QPropertyAnimation(ui->widget, "geometry");
showAnimation->setDuration(100);
showAnimation->setEasingCurve(QEasingCurve::Linear);
showAnimation->setStartValue(formerGeometry);
showAnimation->setEndValue(startgeometry);
showAnimation->start(QPropertyAnimation::DeleteWhenStopped);
}else{
QPropertyAnimation *hideAnimation = new QPropertyAnimation(ui->widget, "geometry");
hideAnimation->setDuration(100);
hideAnimation->setEasingCurve(QEasingCurve::Linear);
hideAnimation->setStartValue(formerGeometry);
QRect finalGeometry
= QRect(endTopLeftCorner,
QSize(ui
->widget
->width
(),
0));
hideAnimation->setEndValue(finalGeometry);
hideAnimation->start(QPropertyAnimation::DeleteWhenStopped);
//ui->widget->hide();//[4]
}
}
MainWindow::MainWindow
{
[...]
//ui->widget->hide();//[1]
//ui->button->setChecked(false);//[2]
startgeometry = QRect(0,0,0,0);
connect(ui->button,SIGNAL(toggled(bool)),this,SLOT(togglePyShell(bool)));
}
void MainWindow::togglePyShell(bool show)
{
QRect formerGeometry = QRect(ui->widget->geometry());
if(startgeometry==QRect(0,0,0,0)){
startgeometry = formerGeometry;
}
if(show){
//ui->widget->show();//[3]
QPropertyAnimation *showAnimation = new QPropertyAnimation(ui->widget, "geometry");
showAnimation->setDuration(100);
showAnimation->setEasingCurve(QEasingCurve::Linear);
showAnimation->setStartValue(formerGeometry);
showAnimation->setEndValue(startgeometry);
showAnimation->start(QPropertyAnimation::DeleteWhenStopped);
}else{
QPropertyAnimation *hideAnimation = new QPropertyAnimation(ui->widget, "geometry");
hideAnimation->setDuration(100);
hideAnimation->setEasingCurve(QEasingCurve::Linear);
hideAnimation->setStartValue(formerGeometry);
QPoint endTopLeftCorner = QPoint(ui->widget->pos() + QPoint(0, ui->widget->height()));
QRect finalGeometry = QRect(endTopLeftCorner, QSize(ui->widget->width(), 0));
hideAnimation->setEndValue(finalGeometry);
hideAnimation->start(QPropertyAnimation::DeleteWhenStopped);
//ui->widget->hide();//[4]
}
}
To copy to clipboard, switch view to plain text mode
Bookmarks