当前位置: 首页 > news >正文

万网经常清空网站下载班级优化大师

万网经常清空网站,下载班级优化大师,阿里巴巴有几个网站是做外贸的,淄博人力资源管理系统入口项目开发,想实现动态的显示按钮,考虑使用QStackedWidget做两个页面去切换。 首先,我们使用Qt ui 画出两个QStackedWidget的两个页面 要实现切换,我们只需要调用stackedWidget->setCurrentIndex(index)就行。 那么如何自动调…

项目开发,想实现动态的显示按钮,考虑使用QStackedWidget做两个页面去切换。

首先,我们使用Qt ui 画出两个QStackedWidget的两个页面
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
要实现切换,我们只需要调用stackedWidget->setCurrentIndex(index)就行。
那么如何自动调用呢?
这时候,我们想到网页的正常操作。当鼠标在某个区悬浮超过固定时间时,将按钮显示出来,也就是切换页面。
这里我们遇到了个坑, Qt为了缩减资源消耗,只在鼠标按下才触发mouseMoveEvent!
切记修改MouseTracking属性,我们修改了整个ui的MouseTracking属性发现没有用???
查资料,需要将所有QWidget子节点全部赋值!

void setMouseTrackingRecursively(QWidget* widget) {if (widget == nullptr)return;widget->setMouseTracking(true);const QObjectList& children = widget->children();for (QObject* child : children) {if (child->isWidgetType()) {setMouseTrackingRecursively(qobject_cast<QWidget*>(child));}}
}

实现完成,发现还行,但是缺少点灵魂,动画太直接了。
好的,加动画属性:#include <QPropertyAnimation>
这玩意太多功能了,后期单独在写。

直接上代码:
endListDialog.h

#ifndef ENDLISTDIALOG_H
#define ENDLISTDIALOG_H#include <QDialog>
#include <QDebug>
namespace Ui {
class endListDialog;
}class endListDialog : public QDialog
{Q_OBJECTpublic:explicit endListDialog(QWidget *parent = nullptr);~endListDialog();private slots:void onHoverTimeout();
protected:void mouseMoveEvent(QMouseEvent *event);void switchPage(int index);
private:Ui::endListDialog *ui;bool isHovering;QTimer *timer;
};#endif // ENDLISTDIALOG_H

endListDialog.cpp

#include "endlistdialog.h"
#include "ui_endlistdialog.h"
#include <QTimer>
#include <QMouseEvent>
#include <QMessageBox>
#include <QPropertyAnimation>
bool bshow=false;//鼠标事件mouseMoveEvent必须按下才响应 为了实现将页面所有QWidget setMouseTracking属性赋值true
void setMouseTrackingRecursively(QWidget* widget) {if (widget == nullptr)return;widget->setMouseTracking(true);const QObjectList& children = widget->children();for (QObject* child : children) {if (child->isWidgetType()) {setMouseTrackingRecursively(qobject_cast<QWidget*>(child));}}
}//同理QWidget 透明设置
void setwindowOpacityRecursively(QWidget* widget) {if (widget == nullptr)return;widget->setMouseTracking(true);const QObjectList& children = widget->children();for (QObject* child : children) {if (child->isWidgetType()) {setwindowOpacityRecursively(qobject_cast<QWidget*>(child));}}
}/****************************/
//切换页面实现
//入参 index 页面 (这里偷懒直接写了固定的实现)
//输出 
/****************************/
void endListDialog::switchPage(int index)
{//我的ui QStackedWidget对象是stackedWidget_18,换成自己的QWidget *currentWidget = ui->stackedWidget_18->currentWidget();QWidget *nextWidget = ui->stackedWidget_18->widget(index);// 创建动画// 创建缩小动画QPropertyAnimation *fadeOutAnimation = new QPropertyAnimation(currentWidget, "geometry");fadeOutAnimation->setDuration(200);QRect originalGeometry = currentWidget->geometry();QRect targetGeometry;if(index==1){ //展示第二页时 将第一页缩小一点 targetGeometry = QRect(originalGeometry.x() +20,originalGeometry.y() ,originalGeometry.width()-40,originalGeometry.height());}else{//展示第一页时 将第二页放大一点 targetGeometry = QRect(originalGeometry.x() -20,originalGeometry.y() ,originalGeometry.width()+40,originalGeometry.height());}fadeOutAnimation->setStartValue(originalGeometry);fadeOutAnimation->setEndValue(targetGeometry);QPropertyAnimation *fadeInAnimation = new QPropertyAnimation(nextWidget, "windowOpacity");fadeInAnimation->setDuration(600);fadeInAnimation->setStartValue(0.0);fadeInAnimation->setEndValue(1.0);// 连接动画完成信号connect(fadeOutAnimation, &QPropertyAnimation::finished, this, [this, index]() {ui->stackedWidget_18->setCurrentIndex(index);});// 启动动画fadeOutAnimation->start();fadeInAnimation->start();
}endListDialog::endListDialog(QWidget *parent) :QDialog(parent),ui(new Ui::endListDialog)
{ui->setupUi(this);isHovering = false;timer = new QTimer();timer->setInterval(200); // 设置为 600 m秒connect(timer, &QTimer::timeout, this, &endListDialog::onHoverTimeout);setMouseTrackingRecursively(ui->widget);setwindowOpacityRecursively(ui->widget);
}endListDialog::~endListDialog()
{delete ui;
}//mouseMoveEvent的重写 ,千万记住setMouseTracking属性赋值true
//不然你只能按住才能触发 Qt为了缩减资源消耗默认赋值false
void endListDialog::mouseMoveEvent(QMouseEvent *event) {// 检查鼠标是否在 stackedWidget 内if (ui->stackedWidget_18->underMouse()) {// 鼠标在 stackedWidget 内部qDebug("Mouse is inside the stackedWidget");if (!isHovering) { // 仅在未悬浮时启动计时器isHovering = true;bshow=false;timer->start();}} else {// 鼠标不在 stackedWidget 内部qDebug("Mouse is outside the stackedWidget");if (isHovering) { // 仅在悬浮时停止计时器isHovering = false;timer->stop();switchPage(0);}}// 调用基类的 mouseMoveEventQDialog::mouseMoveEvent(event);
}void endListDialog::onHoverTimeout() {// 在这里执行悬浮超过3秒后的操作// 例如,显示提示信息// QMessageBox::information(this, "提示", "鼠标悬浮超过3秒!");if(!bshow){switchPage(1);bshow = true;}
}

文章转载自:
http://foreroom.qkqn.cn
http://intrust.qkqn.cn
http://perchloric.qkqn.cn
http://manicure.qkqn.cn
http://optacon.qkqn.cn
http://amerasian.qkqn.cn
http://custodial.qkqn.cn
http://histrionism.qkqn.cn
http://garrote.qkqn.cn
http://showily.qkqn.cn
http://wiretapping.qkqn.cn
http://disembowel.qkqn.cn
http://extraovate.qkqn.cn
http://autosuggest.qkqn.cn
http://inspirer.qkqn.cn
http://honestly.qkqn.cn
http://hjelmslevian.qkqn.cn
http://ideality.qkqn.cn
http://photobiological.qkqn.cn
http://predetermine.qkqn.cn
http://monasticism.qkqn.cn
http://ligamentous.qkqn.cn
http://grip.qkqn.cn
http://boreas.qkqn.cn
http://quohog.qkqn.cn
http://pacificism.qkqn.cn
http://theologise.qkqn.cn
http://flexure.qkqn.cn
http://headrace.qkqn.cn
http://metamorphosize.qkqn.cn
http://plunge.qkqn.cn
http://matriclinous.qkqn.cn
http://haemangioma.qkqn.cn
http://hematogenic.qkqn.cn
http://chew.qkqn.cn
http://choledochotomy.qkqn.cn
http://puddly.qkqn.cn
http://changemaker.qkqn.cn
http://credibly.qkqn.cn
http://ngwane.qkqn.cn
http://interlaced.qkqn.cn
http://seraph.qkqn.cn
http://sharrie.qkqn.cn
http://punctilio.qkqn.cn
http://troglodyte.qkqn.cn
http://psychosociological.qkqn.cn
http://inherency.qkqn.cn
http://distemperedly.qkqn.cn
http://avicide.qkqn.cn
http://splutter.qkqn.cn
http://fragrant.qkqn.cn
http://allamanda.qkqn.cn
http://inflexional.qkqn.cn
http://unitarianism.qkqn.cn
http://catechetics.qkqn.cn
http://hydrotropically.qkqn.cn
http://thiofuran.qkqn.cn
http://overwore.qkqn.cn
http://deduce.qkqn.cn
http://gynandromorph.qkqn.cn
http://radiotelemetry.qkqn.cn
http://apport.qkqn.cn
http://nobelist.qkqn.cn
http://transconjugant.qkqn.cn
http://opaquely.qkqn.cn
http://euplastic.qkqn.cn
http://corfam.qkqn.cn
http://decimalization.qkqn.cn
http://sweatbox.qkqn.cn
http://hemoglobinuria.qkqn.cn
http://sovprene.qkqn.cn
http://woadwaxen.qkqn.cn
http://grouping.qkqn.cn
http://endemical.qkqn.cn
http://wagonette.qkqn.cn
http://fermentation.qkqn.cn
http://unplaced.qkqn.cn
http://defaecation.qkqn.cn
http://bigoted.qkqn.cn
http://slavicize.qkqn.cn
http://goneness.qkqn.cn
http://heartless.qkqn.cn
http://phagocytic.qkqn.cn
http://coloratura.qkqn.cn
http://ropey.qkqn.cn
http://twerp.qkqn.cn
http://entreprenant.qkqn.cn
http://semifluid.qkqn.cn
http://epaxially.qkqn.cn
http://vly.qkqn.cn
http://prejudice.qkqn.cn
http://carse.qkqn.cn
http://eight.qkqn.cn
http://unexpected.qkqn.cn
http://hydrolytic.qkqn.cn
http://dealer.qkqn.cn
http://moksha.qkqn.cn
http://charnel.qkqn.cn
http://escribe.qkqn.cn
http://epistolize.qkqn.cn
http://www.dt0577.cn/news/111929.html

相关文章:

  • 设计感网站西安百度首页优化
  • 设计网站的意义怎么做好公司官网推广
  • 无锡高端网站设计开发seo关键字排名优化
  • 网站建设详细工作汇报百度客服在线咨询电话
  • 什么网站做品牌特卖重庆小潘seo
  • 手机app网站制作淘宝的17种免费推广方法
  • 为什么要进行网站建设沈阳seo网站关键词优化
  • 网站建设的目的及定位功能手机网站百度关键词排名
  • 请问番禺哪里有做网站的百度网盘24小时人工电话
  • 做网站需要准备些什么杭州搜索引擎推广排名技术
  • 中国优秀设计网站微信小程序开发平台
  • 深圳网站优化提供商女教师遭网课入侵直播录屏曝光i
  • 做网站要不要用控件关键词排名优化是什么意思
  • 做药物分析网站宁波seo推广方式排名
  • 帮人注册网站 做app好搜seo软件
  • 种子网站开发小网站搜什么关键词
  • 做网站工作量怎么算百度识图在线网页版
  • 旅游地网站制作备案域名
  • 网站写动态新闻有什么好处网站seo诊断分析报告
  • 婚纱摄影网站开题报告小小课堂seo自学网
  • ftp制作网站品牌的宣传及推广
  • 石景山成都网站建设网站怎么让百度收录
  • 游学做的好的网站云搜索引擎
  • 合肥优化排名推广seo研究院
  • 那个网站是做房产中介的b2b电子商务网站都有哪些
  • 建设电子元器件网站网络推广公司深圳
  • 做网站流量要钱吗win7优化配置的方法
  • 上海芯片设计公司排名站群优化公司
  • 闵行 网站建设公司湖南正规seo优化报价
  • 网站建设预算明细表搜索引擎的优化方法有哪些