zoukankan      html  css  js  c++  java
  • QT窗口渐现效果,窗口震动效果,鼠标移动窗口

    //窗口渐现效果
    void
    MainWindow::closeWindowAnimation() //关闭窗口效果 { QPropertyAnimation *animation = new QPropertyAnimation(this,"windowOpacity"); animation->setDuration(500); animation->setStartValue(1); animation->setEndValue(0); animation->start(); connect(animation,QPropertyAnimation::finished,this,close); } void MainWindow::startAnimation() { QPropertyAnimation *animation = new QPropertyAnimation(this,"windowOpacity"); animation->setDuration(500); animation->setStartValue(0); animation->setEndValue(1); animation->start(); }
    //窗口震动效果
    void
    MainWindow::shakeWindow() { QPropertyAnimation *animation = new QPropertyAnimation(this,"geometry"); animation->setDuration(500); animation->setKeyValueAt(0,QRect(QPoint(this->frameGeometry().x()-3,this->frameGeometry().y()),this->size())); animation->setKeyValueAt(0.1,QRect(QPoint(this->frameGeometry().x()+6,this->frameGeometry().y()),this->size())); animation->setKeyValueAt(0.2,QRect(QPoint(this->frameGeometry().x()-6,this->frameGeometry().y()),this->size())); animation->setKeyValueAt(0.3,QRect(QPoint(this->frameGeometry().x()+6,this->frameGeometry().y()),this->size())); animation->setKeyValueAt(0.4,QRect(QPoint(this->frameGeometry().x()-6,this->frameGeometry().y()),this->size())); animation->setKeyValueAt(0.5,QRect(QPoint(this->frameGeometry().x()+6,this->frameGeometry().y()),this->size())); animation->setKeyValueAt(0.6,QRect(QPoint(this->frameGeometry().x()-6,this->frameGeometry().y()),this->size())); animation->setKeyValueAt(0.7,QRect(QPoint(this->frameGeometry().x()+6,this->frameGeometry().y()),this->size())); animation->setKeyValueAt(0.8,QRect(QPoint(this->frameGeometry().x()-6,this->frameGeometry().y()),this->size())); animation->setKeyValueAt(0.9,QRect(QPoint(this->frameGeometry().x()+6,this->frameGeometry().y()),this->size())); animation->setKeyValueAt(1,QRect(QPoint(this->frameGeometry().x()-3,this->frameGeometry().y()),this->size())); animation->start(); }
    //鼠标移动窗口效果
    void
    MainWindow::mousePressEvent(QMouseEvent *event) { if ( event->button() == Qt::LeftButton ) { startPos = event->globalPos() - this->frameGeometry().topLeft(); qDebug()<<event->globalPos()<<this->frameGeometry().topLeft()<<startPos; } else if ( event->button() == Qt::MiddleButton) closeWindowAnimation(); else if( event->button() == Qt::RightButton ) shakeWindow(); } void MainWindow::mouseMoveEvent(QMouseEvent *event) { if ( event->buttons() == Qt::LeftButton &&startPos.y()<40) { endPos = event->globalPos() - startPos; qDebug()<<endPos; this->move(endPos); } //qDebug()<<event->pos().x(); }
  • 相关阅读:
    使用微软WPF技术开发产品优势究竟在那里
    北京地铁的众生相,发上来和大家分享(北京白领生活真实写照)
    长期提供WindowsPhone7培训 & HTML5培训 & Silverlight培训 & WPF培训
    Silverlight中开发和设计人员的合作
    Silverlight 动态调用 WebService
    (学)Lazarus 在 WinCE 下如何取消标题栏上的 OK 或 X 按钮
    (学)新版动态表单研发,阶段成果4
    (学)新版动态表单研发,阶段成果5
    (原)Lazarus下WinCE终端、服务器心跳监控(Ping)源码
    (原)Lazarus 在 Thread 中使用 SQLQuery 查询Oracle 会出现异常
  • 原文地址:https://www.cnblogs.com/Zengineer/p/4618294.html
Copyright © 2011-2022 走看看