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

网站主页 优帮云/网站网络推广公司

网站主页 优帮云,网站网络推广公司,网站设计存在的问题,金藏源电商网站建设多少钱一、效果图 二、工程构造思路 QPainter绘制单个文本&#xff0c;利用translate和rotate方法旋转单个文字到指定弧度。配合QPropertyAnimation即可实现环形文字效果。 三、代码片段 #ifndef ROUNDTXTWIDGET_H #define ROUNDTXTWIDGET_H#include <QObject> #include <…

一、效果图
在这里插入图片描述
二、工程构造思路
QPainter绘制单个文本,利用translate和rotate方法旋转单个文字到指定弧度。配合QPropertyAnimation即可实现环形文字效果。
三、代码片段

#ifndef ROUNDTXTWIDGET_H
#define ROUNDTXTWIDGET_H#include <QObject>
#include <QWidget>
#include <QPainter>
#include <QFontMetrics>
#include <QPropertyAnimation>
class RoundTxtWidget : public QWidget
{Q_OBJECT
public:RoundTxtWidget(QWidget *parent = nullptr);~RoundTxtWidget();void paintEvent(QPaintEvent *event);void startAnimation();
private slots:void valueChanged_slot(QVariant value);
private:int m_startAngle;int m_margin;QString m_text;
};#endif // ROUNDTXTWIDGET_H
#include "roundtxtwidget.h"
RoundTxtWidget::RoundTxtWidget(QWidget *parent)
{m_text = "abcdefghijklmnopqrstuvwxyz";m_margin = 20;m_startAngle = 0;startAnimation();
}RoundTxtWidget::~RoundTxtWidget()
{}
void RoundTxtWidget::paintEvent(QPaintEvent *event)
{QPainter painter(this);painter.translate(this->width()/2,this->height()/2);painter.rotate(m_startAngle);QFont font;font.setPixelSize(12);painter.setFont(font);painter.save();int textCount = m_text.count();double stepAngle = 360.0 / textCount;painter.setPen(QColor("blue"));QFontMetrics fontm(font);for (int i = 0; i < textCount; i++){int textWidth = fontm.width(m_text.at(i));int textHeight = fontm.height();int radius = qMin(this->width(), this->height()) / 2 - m_margin - textHeight / 2;QRect textRect(-textWidth / 2, -(radius + textHeight / 2), textWidth, textHeight + 1);painter.drawText(textRect, Qt::AlignCenter, m_text.at(i));painter.rotate(stepAngle);}painter.restore();
}
void RoundTxtWidget::startAnimation()
{QPropertyAnimation *pAnimation = new QPropertyAnimation(this, QByteArray());connect(pAnimation, SIGNAL(valueChanged(QVariant)), this, SLOT(valueChanged_slot(QVariant)));pAnimation->setStartValue(0);pAnimation->setEndValue(360);pAnimation->setDuration(6000);pAnimation->setLoopCount(-1);pAnimation->start();
}
void RoundTxtWidget::valueChanged_slot(QVariant value)
{m_startAngle = value.toInt();update();
}

四、结束语
欢迎各方多多指教
QQ:519096571
e-mail:519096571@qq.com

http://www.jmfq.cn/news/5255191.html

相关文章:

  • 专业网站建设联系/企业网站建设模板
  • 云南做网站费用/怎么引流到微信呢
  • seo基础知识/seo全网营销公司
  • 吉安企业做网站/seo 优化技术难度大吗
  • 做微商有卖鞋子的网站吗/今天新闻最新消息
  • 做网站企业的发展前景/深圳今日重大新闻
  • 品牌策划营销/西安百度快照优化
  • 个体户做盈利网站/百度云服务器
  • ipad做电影网站/网络营销的主要传播渠道
  • 甘肃建设网站/成品网站1688入口的功能介绍
  • 在线生成固定悬浮导航的工具网站/合肥seo培训
  • wordpress建m域名网站/每日舆情信息报送
  • wordpress管理页面/镇江seo公司
  • 广州营销型网站制作/有没有免费的写文案的软件
  • 西安网站建设哪个好/营销qq
  • 政务内网网站群建设/西安网站到首页排名
  • 长沙做网站多少钱/seo有哪些网站
  • 东莞模板网站设计/百度搜索引擎原理
  • 河北恒山建设集团网站/营销策划方案怎么做
  • 免费网站建设视频教程/中国最新军事新闻最新消息
  • 昆山做网站的/168推广网
  • 惠州seo外包服务/南京seo网站优化
  • 西安做网站找缑阳建/腾讯广告推广平台入口
  • 企业 网站微信 建设/莆田百度推广开户
  • wordpress编辑器段间距/优化网站内容的方法
  • 福田网站建设设计/厦门seo俱乐部
  • 唐山哪里有做网站的/晋城网站seo
  • 关于旅游网站策划书/国内最新新闻
  • 施坦威网站关于我们/深圳百度推广电话
  • 网站研发公司/windows优化大师要钱