网站调用微信js视频,网站优化排名易下拉用法,上海猎头公司前十名,有没有专业做艺术品的网站目标功能#xff1a;
(1)按下btn#xff0c;弹出绿色页面。 (2)按下btn2,绿色页面隐藏。 (3)按下左边余下的区域#xff0c;绿色页面也隐藏。
(4)平滑地显示和隐藏
效果#xff1a; form.h
#ifndef FORM_H
#define FORM_H#include QWidgetnamespace Ui {
class…目标功能
(1)按下btn弹出绿色页面。 (2)按下btn2,绿色页面隐藏。 (3)按下左边余下的区域绿色页面也隐藏。
(4)平滑地显示和隐藏
效果 form.h
#ifndef FORM_H
#define FORM_H#include QWidgetnamespace Ui {
class Form;
}class Form : public QWidget
{Q_OBJECTpublic:explicit Form(QWidget *parent nullptr);~Form();private slots:void on_pushButton_clicked();private:Ui::Form *ui;
signals:void begin_move();
};#endif // FORM_Hform.cpp
#include form.h
#include ui_form.hForm::Form(QWidget *parent) :QWidget(parent),ui(new Ui::Form)
{ui-setupUi(this);
}Form::~Form()
{delete ui;
}void Form::on_pushButton_clicked()
{emit begin_move();
}widget.h
#ifndef WIDGET_H
#define WIDGET_H#include QWidget
#include form.h
#include QPropertyAnimation
#include QMouseEvent
QT_BEGIN_NAMESPACE
namespace Ui { class Widget; }
QT_END_NAMESPACEclass Widget : public QWidget
{Q_OBJECTpublic:Widget(QWidget *parent nullptr);~Widget();
protected:void mousePressEvent(QMouseEvent *event) override;bool eventFilter(QObject *obj,QEvent *event) override;
private slots:void on_pushButton_clicked();
private:Ui::Widget *ui;Form *f;QPropertyAnimation *animation,*animation1;bool flag;bool isShow;
};
#endif // WIDGET_Hwidget.cpp
#include widget.h
#include ui_widget.h
#include QDebug
#include QEvent#pragma execution_character_set(utf-8)
Widget::Widget(QWidget *parent): QWidget(parent), ui(new Ui::Widget)
{ui-setupUi(this);fnew Form(this);f-hide();flag1;isShow0;ui-pushButton_2-installEventFilter(this);connect(f,Form::begin_move,this,[](){if(isShow 1){animation1-start();isShow0;}});
}Widget::~Widget()
{delete ui;
}void Widget::mousePressEvent(QMouseEvent *event)
{if(event-button()Qt::LeftButton){qDebug()按下了鼠标左键;qDebug()event-pos();if(isShow 1){animation1-start();isShow0;}}
}bool Widget::eventFilter(QObject *obj, QEvent *event)
{if(objui-pushButton_2){if(event-type() QEvent::MouseButtonPress){qDebug()按下按钮;QMouseEvent * me static_castQMouseEvent *(event);if(me-button() Qt::LeftButton){qDebug()按下左键;if(isShow 1){animation1-start();isShow0;}}return false;}}return QWidget::eventFilter(obj,event);
}void Widget::on_pushButton_clicked()
{if(flag1){flag0;f-resize(300,height());f-move(width(),0);f-show();animation new QPropertyAnimation(f,pos);animation-setDuration(1000); //设置动画完成的时间长度animation-setStartValue(QPoint(width(),0)); //设置动画的开始值animation-setEndValue(QPoint(width()-f-width(),0)); //设置动画的结束值animation1 new QPropertyAnimation(f,pos);animation1-setDuration(1000); //设置动画完成的时间长度animation1-setStartValue(QPoint(width()-f-width(),0)); //设置动画的开始值animation1-setEndValue(QPoint(width(),0)); //设置动画的结束值}animation-start(); //启动动画isShow1;
}