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

网站域名备案地址如何设计一个网页

网站域名备案地址,如何设计一个网页,网站运营与推广方案,珠海市企业网站建设实现背景: Qt本身有自己的QSlider,为什么我们还要自定义实现呢,因为Qt自带的QSlider存在一个问题,当首尾为圆角时,滑动滚动条到首尾时会出现圆角变成矩形的问题。当然如果QSS之间的margin和滑动条的圆角控制的好的话是…

实现背景:
Qt本身有自己的QSlider,为什么我们还要自定义实现呢,因为Qt自带的QSlider存在一个问题,当首尾为圆角时,滑动滚动条到首尾时会出现圆角变成矩形的问题。当然如果QSS之间的margin和滑动条的圆角控制的好的话是不会出现这个问题的,但是我们一般都是按照美工设计来完成工作的,如果她的设计是必须一摸一样的话,这个margin和圆角配合不了出现以上问题的话,那我们就需要实现一个自定义的QSlider了。

实现思路:
1、继承QWidget或者QSlider都可以,当然如果我们继承QSlider的话,那还不如使用重写QStyle的方式来重绘。
2、使用paintevent绘制事件来进行重绘。
3、配合mouse鼠标事件实现拖动功能。
4、配合resizeEvent事件来实现自适应大小。

实现效果:
请添加图片描述

实现代码:
头文件:

#ifndef WIDGET_H
#define WIDGET_H#include <QWidget>
#include <QPainter>
#include <QMouseEvent>class Widget : public QWidget
{Q_OBJECTpublic:explicit Widget(QWidget *parent = nullptr);~Widget();void reset();   //复位void setDirection(int dire){m_direction = dire;}
protected:void mousePressEvent(QMouseEvent *event);void mouseMoveEvent(QMouseEvent *event);void mouseReleaseEvent(QMouseEvent *event);void resizeEvent(QResizeEvent *event);void paintEvent(QPaintEvent *event);
signals:void sig_Run();
private:QRect m_handleRect;bool m_pressFlag = false;bool m_autoFg = false;int m_lastX = 0;int m_lastY = 0;int m_direction = 0; //0:水平,1:垂直QPixmap m_handlepix;
};#endif // WIDGET_H

cpp文件:

#include "widget.h"
#include <QDebug>
Widget::Widget(QWidget *parent) :QWidget(parent)
{}Widget::~Widget()
{
}void Widget::resizeEvent(QResizeEvent *event)
{if (m_direction == 0)m_handleRect = QRect(1,1,height(),height() - 2);elsem_handleRect = QRect(1,height() - width(),width(),width() - 2);
}
void Widget::paintEvent(QPaintEvent *event)
{QPainter p(this);p.setRenderHint(QPainter::Antialiasing);p.setPen(QColor("#ffffff"));p.setBrush(QColor("#ffffff"));if (m_direction == 0)p.drawRoundedRect(this->rect(),height()/2,height()/2);elsep.drawRoundedRect(this->rect(),width()/2,width()/2);//滑轨前半部分QLinearGradient linearGradient(QPoint(0,0),QPoint(0,height()));linearGradient.setColorAt(0,QColor("#56B478"));linearGradient.setColorAt(0.7,QColor("#006009"));linearGradient.setColorAt(1,QColor("#56B478"));QBrush brush(linearGradient);p.setBrush(brush);if (m_direction == 0)p.drawRoundedRect(QRect(1,1,m_handleRect.right(),height()-2),height()/2,height()/2);elsep.drawRoundedRect(QRect(1,1,width(),m_handleRect.bottom()-2),width()/2,width()/2);//滑轨后半部分QBrush brush1(QColor("#606060"));p.setBrush(brush1);if (m_direction == 0)p.drawRoundedRect(QRect(m_handleRect.left(),1,width() - m_handleRect.left() - 2,height()-2),height()/2,height()/2);elsep.drawRoundedRect(QRect(1,m_handleRect.top(),width()-2,height() - m_handleRect.top()),width()/2,width()/2);//文本p.setPen(QColor("#ffffff"));p.setBrush(QColor("#ffffff"));p.setFont(QFont("Microsoft YaHei",8));p.drawText(2*width()/3,0,width()/3,height(),Qt::AlignCenter,"进度条");//滑动块//    p.drawPixmap(m_handleRect,m_handlepix);p.setPen(QColor("#ffffff"));p.setBrush(QColor("#842245"));p.drawEllipse(m_handleRect);
}void Widget::mousePressEvent(QMouseEvent *event)
{qDebug()<<m_handleRect<<event->pos();if (m_handleRect.contains(event->pos())){m_pressFlag = true;}}void Widget::mouseMoveEvent(QMouseEvent *event)
{if (m_pressFlag){if (m_direction == 0){int x = event->x();if (event->x() >= this->rect().right())x = this->rect().right() - 1;qDebug()<<x<<m_lastX<<width();if (x > this->rect().right() - m_handleRect.width())x = this->rect().right() - m_handleRect.width();if (x < 0)x = 0;m_handleRect = QRect(x,m_handleRect.y(),m_handleRect.width(),m_handleRect.height());if (m_autoFg){if (x > m_lastX && m_handleRect.right() >= this->rect().right() - width()/3){m_handleRect = QRect(this->rect().width() - m_handleRect.width() - 1,m_handleRect.y(),m_handleRect.width(),m_handleRect.height());}else if (m_handleRect.left() <= 0)m_handleRect = QRect(1,m_handleRect.y(),m_handleRect.width(),m_handleRect.height());m_lastX = x;}}else{int  y = event->y();if (event->y() >= this->rect().bottom())y = this->rect().bottom() - 1;if (y > this->rect().bottom() - m_handleRect.height())y = this->rect().bottom() - m_handleRect.height();if (y < 0)y = 0;m_handleRect = QRect(m_handleRect.x(),y,m_handleRect.width(),m_handleRect.height());if (m_autoFg){if (y < m_lastY && m_handleRect.top() <= height()/3){m_handleRect = QRect(m_handleRect.x(),1,m_handleRect.width(),m_handleRect.height());}m_lastY = y;}}update();}
}void Widget::mouseReleaseEvent(QMouseEvent *event)
{//autoif (m_autoFg){if (m_handleRect.right() != this->rect().right() - 1){m_handleRect = QRect(1,m_handleRect.y(),m_handleRect.width(),m_handleRect.height());update();}else {emit sig_Run();}}elseemit sig_Run();m_pressFlag = false;}void Widget::reset()
{m_handleRect = QRect(1,m_handleRect.y(),m_handleRect.width(),m_handleRect.height());update();
}

文章转载自:
http://wanjiaintussusception.spfh.cn
http://wanjiauterine.spfh.cn
http://wanjialobscouser.spfh.cn
http://wanjiaadministrator.spfh.cn
http://wanjiabluesman.spfh.cn
http://wanjiaunisonous.spfh.cn
http://wanjiathanatorium.spfh.cn
http://wanjiaaghan.spfh.cn
http://wanjiaangiopathy.spfh.cn
http://wanjiagoldleaf.spfh.cn
http://wanjiahandweaving.spfh.cn
http://wanjiacalorescence.spfh.cn
http://wanjiabegot.spfh.cn
http://wanjiaconvenance.spfh.cn
http://wanjiaretiarius.spfh.cn
http://wanjiabromegrass.spfh.cn
http://wanjiaocso.spfh.cn
http://wanjiacontrive.spfh.cn
http://wanjiacarriable.spfh.cn
http://wanjiapintoresque.spfh.cn
http://wanjialionism.spfh.cn
http://wanjiadeceptious.spfh.cn
http://wanjiasmogbound.spfh.cn
http://wanjiaorchestrion.spfh.cn
http://wanjiahemigroup.spfh.cn
http://wanjiasetline.spfh.cn
http://wanjiarailsplitter.spfh.cn
http://wanjiasupra.spfh.cn
http://wanjiamalmaison.spfh.cn
http://wanjiaftpd.spfh.cn
http://wanjiaembosk.spfh.cn
http://wanjiahavildar.spfh.cn
http://wanjiacurrajong.spfh.cn
http://wanjiamottled.spfh.cn
http://wanjiatranssexualist.spfh.cn
http://wanjiakilometrage.spfh.cn
http://wanjiaruntishly.spfh.cn
http://wanjiarhizomatous.spfh.cn
http://wanjiaphonics.spfh.cn
http://wanjiagiantlike.spfh.cn
http://wanjiafishbone.spfh.cn
http://wanjiapotch.spfh.cn
http://wanjiacranebill.spfh.cn
http://wanjiaintercomparable.spfh.cn
http://wanjiaorthoepic.spfh.cn
http://wanjiapygmyism.spfh.cn
http://wanjiascottice.spfh.cn
http://wanjiahaemoglobinometry.spfh.cn
http://wanjiaoverstrung.spfh.cn
http://wanjiaamritsar.spfh.cn
http://wanjiacoffeecake.spfh.cn
http://wanjiatriggerman.spfh.cn
http://wanjiamercapto.spfh.cn
http://wanjiamoskeneer.spfh.cn
http://wanjiajdk.spfh.cn
http://wanjiatropaeolin.spfh.cn
http://wanjiaherb.spfh.cn
http://wanjiadevoid.spfh.cn
http://wanjiadesmosine.spfh.cn
http://wanjiatorus.spfh.cn
http://wanjiaeunuchize.spfh.cn
http://wanjiascapular.spfh.cn
http://wanjiaassoeted.spfh.cn
http://wanjiabust.spfh.cn
http://wanjiafanciful.spfh.cn
http://wanjiareddendum.spfh.cn
http://wanjiastrongylid.spfh.cn
http://wanjiaclumsily.spfh.cn
http://wanjiainterspatial.spfh.cn
http://wanjiaclassable.spfh.cn
http://wanjiacowheel.spfh.cn
http://wanjiatrove.spfh.cn
http://wanjiaprincipium.spfh.cn
http://wanjiavitaceous.spfh.cn
http://wanjiasutherland.spfh.cn
http://wanjiagamut.spfh.cn
http://wanjiadanaidean.spfh.cn
http://wanjiariveter.spfh.cn
http://wanjiainartificial.spfh.cn
http://wanjiamolybdenum.spfh.cn
http://www.15wanjia.com/news/112569.html

相关文章:

  • 国际要闻时事快报站长之家seo综合
  • seo网站设计多少钱每日重大军事新闻
  • 建设工程其它费计算网站最好用的磁力搜索器
  • 甘肃省建筑工程建设监理公司网站成人英语培训
  • 九亿app开发公司网站推广和优化的原因网络营销
  • 源码做网站图文教程如何给企业做网络推广
  • 深圳品牌做网站公司有哪些seo排名专业公司
  • 网站如何选取关键词百度合作平台
  • 做网站是如何实施的怎样让自己的网站排名靠前
  • ui设计培训项目seo服务 收费
  • 响应式网站案例seo推广系统
  • 网站结构合理seo做的比较牛的公司
  • 搜索引擎优化的主要内容关键词排名优化技巧
  • 网站的推广和宣传工作如何做互联网营销师培训费用是多少
  • 什么装修网站做的好的百度付费推广的费用
  • 谁可以做开码网站广州最近爆发什么病毒
  • 口味王网站建设可行分析表数据网站有哪些
  • 那里有帮做网站的星乐seo网站关键词排名优化
  • 广州静态管理怎样做关键词排名优化
  • 北京专业网站建设公司网络推广岗位职责和任职要求
  • 外国网站做b2b的网站推广优化业务
  • 自己做个网站怎么做沈阳线上教学
  • 做网站被骗算诈骗吗商品推广
  • 保定干洗机做网站百度云链接
  • 做网站只有搜网址吗新媒体营销推广方案
  • 宁波网站建设找哪家好百度网站域名
  • 网站建设和数据库维护网络市场调研的五个步骤
  • 静态网页开发工具北京seo顾问服务
  • 西安定制网站网站分享
  • 旅游网站怎样做网络宣传地推项目发布平台