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

我的世界怎么做购买点卷网站专业网站设计公司排行榜

我的世界怎么做购买点卷网站,专业网站设计公司排行榜,手机网站怎么搜索引擎,一键生成海报一、2024 永不卡顿 爱的魔力它转圈圈~ 等待样式控件是我们在做UI时出场率还挺高的控件之一#xff0c;通常情况下有如下的几种实现方式#xff1a; 1 获取一张gif的资源图#xff0c;然后使用QMovie 在一个QLabel 控件上加载显示gif的waiting等待动态。 2 自定义绘图…一、2024 永不卡顿 爱的魔力它转圈圈~ 等待样式控件是我们在做UI时出场率还挺高的控件之一通常情况下有如下的几种实现方式 1 获取一张gif的资源图然后使用QMovie 在一个QLabel 控件上加载显示gif的waiting等待动态。 2 自定义绘图然后使用Qt动画达到转圈圈的效果。本文以此方式为例给大家一个好看的样式示例。 本篇作为搬运工https://github.com/snowwlex/QtWaitingSpinner 二、代码示例 使用草鸡简单提供了一些接口用于waiting 标签的修改。 #include QCoreApplication #include QApplication #include waitingspinnerwidget.h #include QFrame #include QHBoxLayoutint main(int argc,char* argv[]) {QApplication a(argc,argv);WaitingSpinnerWidget* spinner new WaitingSpinnerWidget;/// 设置waiting组件的样式spinner-setRoundness(70.0);spinner-setMinimumTrailOpacity(15.0);spinner-setTrailFadePercentage(70.0);spinner-setNumberOfLines(12);spinner-setLineLength(10);spinner-setLineWidth(5);spinner-setInnerRadius(10);spinner-setRevolutionsPerSecond(1);spinner-setColor(QColor(81, 4, 71));spinner-start(); // gets the show on the road!QFrame* f new QFrame;QHBoxLayout* hlayout new QHBoxLayout;hlayout-addWidget(spinner);f-setLayout(hlayout);f-show();return a.exec(); } 具体实现代码如下 // waitingspinnerwidget.h/* Original Work Copyright (c) 2012-2014 Alexander TurkinModified 2014 by William HallattModified 2015 by Jacob Dawid Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the Software), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.THE SOFTWARE IS PROVIDED AS IS, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */#pragma once// Qt includes #include QWidget #include QTimer #include QColorclass WaitingSpinnerWidget : public QWidget {Q_OBJECT public:/*! Constructor for standard widget behaviour - use this* constructor if you wish to, e.g. embed your widget in another. */WaitingSpinnerWidget(QWidget *parent 0,bool centerOnParent true,bool disableParentWhenSpinning true);/*! Constructor - use this constructor to automatically create a modal* (blocking) spinner on top of the calling widget/window. If a valid* parent widget is provided, centreOnParent will ensure that* QtWaitingSpinner automatically centres itself on it, if not,* centreOnParent is ignored. */WaitingSpinnerWidget(Qt::WindowModality modality,QWidget *parent 0,bool centerOnParent true,bool disableParentWhenSpinning true);public slots:void start();void stop();public:void setColor(QColor color);void setRoundness(qreal roundness);void setMinimumTrailOpacity(qreal minimumTrailOpacity);void setTrailFadePercentage(qreal trail);void setRevolutionsPerSecond(qreal revolutionsPerSecond);void setNumberOfLines(int lines);void setLineLength(int length);void setLineWidth(int width);void setInnerRadius(int radius);void setText(QString text);QColor color();qreal roundness();qreal minimumTrailOpacity();qreal trailFadePercentage();qreal revolutionsPersSecond();int numberOfLines();int lineLength();int lineWidth();int innerRadius();bool isSpinning() const;private slots:void rotate();protected:void paintEvent(QPaintEvent *paintEvent);private:static int lineCountDistanceFromPrimary(int current, int primary,int totalNrOfLines);static QColor currentLineColor(int distance, int totalNrOfLines,qreal trailFadePerc, qreal minOpacity,QColor color);void initialize();void updateSize();void updateTimer();void updatePosition();private:QColor _color;qreal _roundness; // 0..100qreal _minimumTrailOpacity;qreal _trailFadePercentage;qreal _revolutionsPerSecond;int _numberOfLines;int _lineLength;int _lineWidth;int _innerRadius;private:WaitingSpinnerWidget(const WaitingSpinnerWidget);WaitingSpinnerWidget operator(const WaitingSpinnerWidget);QTimer *_timer;bool _centerOnParent;bool _disableParentWhenSpinning;int _currentCounter;bool _isSpinning; }; // waitingspinnerwidget.cpp/* Original Work Copyright (c) 2012-2014 Alexander TurkinModified 2014 by William HallattModified 2015 by Jacob DawidPermission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the Software), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.THE SOFTWARE IS PROVIDED AS IS, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */// Own includes #include waitingspinnerwidget.h// Standard includes #include cmath #include algorithm// Qt includes #include QPainter #include QTimerWaitingSpinnerWidget::WaitingSpinnerWidget(QWidget *parent,bool centerOnParent,bool disableParentWhenSpinning): QWidget(parent),_centerOnParent(centerOnParent),_disableParentWhenSpinning(disableParentWhenSpinning) {initialize(); }WaitingSpinnerWidget::WaitingSpinnerWidget(Qt::WindowModality modality,QWidget *parent,bool centerOnParent,bool disableParentWhenSpinning): QWidget(parent, Qt::Dialog | Qt::FramelessWindowHint),_centerOnParent(centerOnParent),_disableParentWhenSpinning(disableParentWhenSpinning){initialize();// We need to set the window modality AFTER weve hidden the// widget for the first time since changing this property while// the widget is visible has no effect.setWindowModality(modality);setAttribute(Qt::WA_TranslucentBackground); }void WaitingSpinnerWidget::initialize() {_color Qt::black;_roundness 100.0;_minimumTrailOpacity 3.14159265358979323846;_trailFadePercentage 80.0;_revolutionsPerSecond 1.57079632679489661923;_numberOfLines 20;_lineLength 10;_lineWidth 2;_innerRadius 10;_currentCounter 0;_isSpinning false;_timer new QTimer(this);connect(_timer, SIGNAL(timeout()), this, SLOT(rotate()));updateSize();updateTimer();hide(); }void WaitingSpinnerWidget::paintEvent(QPaintEvent *) {updatePosition();QPainter painter(this);painter.fillRect(this-rect(), Qt::transparent);painter.setRenderHint(QPainter::Antialiasing, true);if (_currentCounter _numberOfLines) {_currentCounter 0;}painter.setPen(Qt::NoPen);for (int i 0; i _numberOfLines; i) {painter.save();painter.translate(_innerRadius _lineLength,_innerRadius _lineLength);qreal rotateAngle static_castqreal(360 * i) / static_castqreal(_numberOfLines);painter.rotate(rotateAngle);painter.translate(_innerRadius, 0);int distance lineCountDistanceFromPrimary(i, _currentCounter, _numberOfLines);QColor color currentLineColor(distance, _numberOfLines, _trailFadePercentage,_minimumTrailOpacity, _color);painter.setBrush(color);// TODO improve the way rounded rect is paintedpainter.drawRoundedRect(QRect(0, -_lineWidth / 2, _lineLength, _lineWidth), _roundness,_roundness, Qt::RelativeSize);painter.restore();} }void WaitingSpinnerWidget::start() {updatePosition();_isSpinning true;show();if(parentWidget() _disableParentWhenSpinning) {parentWidget()-setEnabled(false);}if (!_timer-isActive()) {_timer-start();_currentCounter 0;} }void WaitingSpinnerWidget::stop() {_isSpinning false;hide();if(parentWidget() _disableParentWhenSpinning) {parentWidget()-setEnabled(true);}if (_timer-isActive()) {_timer-stop();_currentCounter 0;} }void WaitingSpinnerWidget::setNumberOfLines(int lines) {_numberOfLines lines;_currentCounter 0;updateTimer(); }void WaitingSpinnerWidget::setLineLength(int length) {_lineLength length;updateSize(); }void WaitingSpinnerWidget::setLineWidth(int width) {_lineWidth width;updateSize(); }void WaitingSpinnerWidget::setInnerRadius(int radius) {_innerRadius radius;updateSize(); }QColor WaitingSpinnerWidget::color() {return _color; }qreal WaitingSpinnerWidget::roundness() {return _roundness; }qreal WaitingSpinnerWidget::minimumTrailOpacity() {return _minimumTrailOpacity; }qreal WaitingSpinnerWidget::trailFadePercentage() {return _trailFadePercentage; }qreal WaitingSpinnerWidget::revolutionsPersSecond() {return _revolutionsPerSecond; }int WaitingSpinnerWidget::numberOfLines() {return _numberOfLines; }int WaitingSpinnerWidget::lineLength() {return _lineLength; }int WaitingSpinnerWidget::lineWidth() {return _lineWidth; }int WaitingSpinnerWidget::innerRadius() {return _innerRadius; }bool WaitingSpinnerWidget::isSpinning() const {return _isSpinning; }void WaitingSpinnerWidget::setRoundness(qreal roundness) {_roundness std::max(0.0, std::min(100.0, roundness)); }void WaitingSpinnerWidget::setColor(QColor color) {_color color; }void WaitingSpinnerWidget::setRevolutionsPerSecond(qreal revolutionsPerSecond) {_revolutionsPerSecond revolutionsPerSecond;updateTimer(); }void WaitingSpinnerWidget::setTrailFadePercentage(qreal trail) {_trailFadePercentage trail; }void WaitingSpinnerWidget::setMinimumTrailOpacity(qreal minimumTrailOpacity) {_minimumTrailOpacity minimumTrailOpacity; }void WaitingSpinnerWidget::rotate() {_currentCounter;if (_currentCounter _numberOfLines) {_currentCounter 0;}update(); }void WaitingSpinnerWidget::updateSize() {int size (_innerRadius _lineLength) * 2;setFixedSize(size, size); }void WaitingSpinnerWidget::updateTimer() {_timer-setInterval(1000 / (_numberOfLines * _revolutionsPerSecond)); }void WaitingSpinnerWidget::updatePosition() {if (parentWidget() _centerOnParent) {move(parentWidget()-width() / 2 - width() / 2,parentWidget()-height() / 2 - height() / 2);} }int WaitingSpinnerWidget::lineCountDistanceFromPrimary(int current, int primary,int totalNrOfLines) {int distance primary - current;if (distance 0) {distance totalNrOfLines;}return distance; }QColor WaitingSpinnerWidget::currentLineColor(int countDistance, int totalNrOfLines,qreal trailFadePerc, qreal minOpacity,QColor color) {if (countDistance 0) {return color;}const qreal minAlphaF minOpacity / 100.0;int distanceThreshold static_castint(ceil((totalNrOfLines - 1) * trailFadePerc / 100.0));if (countDistance distanceThreshold) {color.setAlphaF(minAlphaF);} else {qreal alphaDiff color.alphaF() - minAlphaF;qreal gradient alphaDiff / static_castqreal(distanceThreshold 1);qreal resultAlpha color.alphaF() - gradient * countDistance;// If alpha is out of bounds, clip it.resultAlpha std::min(1.0, std::max(0.0, resultAlpha));color.setAlphaF(resultAlpha);}return color; }三、祝愿 本章代码小而美生活中也有无数个小美好。 祝愿朋友们新年一路向上事业永不卡顿共赴美好开启新征程~
http://www.zqtcl.cn/news/305251/

相关文章:

  • 洪雅网站建设事业单位门户网站建设包含内容
  • 外网如何查看局域网建设的网站区块链开发工程师要求
  • 网站首页三张海报做多大怎么做网上直营店网站
  • 网站制作新手教程视频省建设厅网站安全生产标准化
  • 自动建设网站系统阿里云虚拟主机多网站
  • 区块链app排名网站seo其应用
  • 海口网站建设咨询一般网站建设需求有哪些方面
  • 免费网站建设朋友交流模板王网站
  • wordpress不同分类不同广告 文章属于不同分类网站 优化手机版
  • 淮安市建设银行网站首页王也是谁
  • 好用的网站管理系统给wordpress程序提速
  • 网页设计模板的网站网站开发包括哪些
  • 做网站的标准国外html5网站模板
  • 手机网站设计公司立找亿企邦郑州seo网络营销技术
  • 网站设计优秀作品网站开发的背景知识
  • 响应式网站建设流程温州网站优化案例
  • 谢岗镇网站建设上海的网吧
  • 厦门网站建设 智多星做印刷的有什么网站
  • 怎样做原创短视频网站wordpress文章加音频
  • 建设一个网站所需要注意的最有前途的15个专业
  • 橱柜手机网站模板软件设计说明书
  • 山西云起时网站建设wordpress 字体大小
  • 网站建设详细报价电商开发系统
  • 搜索引擎营销的主要方法开封seo推广
  • 怎么在网上找做网站的客户安徽安能建设集团网站
  • 乾安网站建设哪家专业h5在线编辑
  • 公司网站建设模块简介广17网站一起做网店
  • 外包网站多少钱柳市建设网站
  • 做外贸站推广全国网页制作大赛
  • 手机网站关键词排名微信小程序怎么做网页