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

网站建设图片app代理推广合作

网站建设图片,app代理推广合作,全国各大网站,怀宁县住房和城乡建设局网站✨博客主页何曾参静谧的博客📌文章专栏「QT」QT5程序设计📚全部专栏「VS」Visual Studio「C/C」C/C程序设计「UG/NX」BlockUI集合「Win」Windows程序设计「DSA」数据结构与算法「UG/NX」NX二次开发「QT」QT5程序设计「File」数据文件格式「PK」Parasolid…

在这里插入图片描述

✨博客主页
何曾参静谧的博客
📌文章专栏
「QT」QT5程序设计
📚全部专栏
「VS」Visual Studio「C/C++」C/C++程序设计「UG/NX」BlockUI集合
「Win」Windows程序设计「DSA」数据结构与算法「UG/NX」NX二次开发
「QT」QT5程序设计「File」数据文件格式「PK」Parasolid函数说明
「Math」探秘数学世界

目录

    • QPoint类详解
      • 一、引言
      • 二、使用范围
      • 三、类的头文件
      • 四、类的构造介绍
      • 五、共有函数介绍
      • 六、Static函数介绍
      • 七、运算符重载
      • 八、详细代码举例

QPoint类详解

一、引言

QPoint是Qt框架中的一个核心类,它用于表示二维平面上的一个点。QPoint类提供了丰富的功能,包括点的坐标操作、向量运算以及与其他Qt类的集成。作为Qt绘图和图形界面设计的基础,QPoint类在Qt应用程序中扮演着重要的角色。

二、使用范围

QPoint类广泛应用于Qt的图形编程和界面设计中。它不仅可以用于表示图形界面中的点位置,还可以作为向量进行加减乘除等运算。此外,QPoint类还常用于处理鼠标事件、绘制图形以及进行图形变换等场景。

三、类的头文件

要使用QPoint类,需要包含其头文件<QPoint>。这个头文件定义了QPoint类的所有成员和函数,使得开发者可以在自己的Qt应用程序中使用该类。

#include <QPoint>

四、类的构造介绍

QPoint类提供了两种构造函数:

  1. 默认构造函数:创建一个横纵坐标均为0的QPoint对象。
QPoint();
  1. 参数化构造函数:创建一个横纵坐标分别为指定值的QPoint对象。
QPoint(int xpos, int ypos);

五、共有函数介绍

QPoint类提供了多个共有函数,用于获取和设置点的坐标、进行向量运算等。以下是一些常用的共有函数:

  • int x() const:获取点的横坐标。
  • int y() const:获取点的纵坐标。
  • void setX(int x):设置点的横坐标。
  • void setY(int y):设置点的纵坐标。
  • QPoint &operator+=(const QPoint &point):将当前点与另一个点相加,结果存储在当前点中。
  • QPoint &operator-=(const QPoint &point):将当前点与另一个点相减,结果存储在当前点中。
  • int manhattanLength() const:计算当前点作为向量时的曼哈顿长度(即横纵坐标绝对值之和)。

六、Static函数介绍

QPoint类还提供了一个静态函数dotProduct,用于计算两个点的点积。

static int dotProduct(const QPoint &p1, const QPoint &p2);

该函数接受两个QPoint对象作为参数,并返回它们的点积结果。

七、运算符重载

QPoint类重载了多个运算符,使得该类可以像基本数据类型一样进行运算。以下是一些重载的运算符:

  • QPoint operator+(const QPoint &point):两个点相加,返回一个新的QPoint对象。
  • QPoint operator-(const QPoint &point):两个点相减,返回一个新的QPoint对象。
  • QPoint operator*(int factor):将点乘以一个整数因子,返回一个新的QPoint对象。
  • QPoint operator/(qreal divisor):将点除以一个实数因子,返回一个新的QPoint对象。
  • bool operator==(const QPoint &other):判断两个点是否相等。
  • bool operator!=(const QPoint &other):判断两个点是否不相等。

八、详细代码举例

以下是一个使用QPoint类的详细代码示例,展示了如何创建QPoint对象、获取和设置坐标、进行向量运算以及计算曼哈顿长度。

#include <QCoreApplication>
#include <QPoint>
#include <QDebug>int main(int argc, char *argv[])
{QCoreApplication a(argc, argv);// 创建两个QPoint对象QPoint point1(3, 4);QPoint point2(1, 2);// 获取点的坐标int x1 = point1.x();int y1 = point1.y();qDebug() << "Point1:" << x1 << "," << y1;int x2 = point2.x();int y2 = point2.y();qDebug() << "Point2:" << x2 << "," << y2;// 设置点的坐标point1.setX(5);point1.setY(6);qDebug() << "After setting, Point1:" << point1.x() << "," << point1.y();// 向量运算QPoint point3 = point1 + point2;qDebug() << "Point1 + Point2 = Point3:" << point3.x() << "," << point3.y();QPoint point4 = point1 - point2;qDebug() << "Point1 - Point2 = Point4:" << point4.x() << "," << point4.y();QPoint point5 = point1 * 2;qDebug() << "Point1 * 2 = Point5:" << point5.x() << "," << point5.y();// 计算曼哈顿长度int length = point1.manhattanLength();qDebug() << "Manhattan length of Point1:" << length;return a.exec();
}

在这个示例中,我们首先创建了两个QPoint对象point1point2,并获取了它们的坐标。然后,我们设置了point1的新坐标,并进行了向量加法、减法和乘法运算。最后,我们计算了point1的曼哈顿长度,并将所有结果输出到控制台。

通过本文的介绍,相信读者已经对Qt中的QPoint类有了深入的了解。在实际开发中,可以根据需要灵活运用QPoint类来处理二维平面上的点坐标和向量运算。


在这里插入图片描述


文章转载自:
http://dinncoclamworm.zfyr.cn
http://dinncobeforehand.zfyr.cn
http://dinncocpsu.zfyr.cn
http://dinncoheliolatry.zfyr.cn
http://dinncocollocate.zfyr.cn
http://dinncoembower.zfyr.cn
http://dinncoshapely.zfyr.cn
http://dinncooona.zfyr.cn
http://dinncowoodiness.zfyr.cn
http://dinncomormondom.zfyr.cn
http://dinncouncriticized.zfyr.cn
http://dinncoheritage.zfyr.cn
http://dinncooscan.zfyr.cn
http://dinncotopdressing.zfyr.cn
http://dinncochoric.zfyr.cn
http://dinncopseudonymous.zfyr.cn
http://dinnconobiliary.zfyr.cn
http://dinnconihil.zfyr.cn
http://dinncomamba.zfyr.cn
http://dinncoslave.zfyr.cn
http://dinncostaff.zfyr.cn
http://dinncochippewa.zfyr.cn
http://dinncoanelectric.zfyr.cn
http://dinncohomothetic.zfyr.cn
http://dinncoallargando.zfyr.cn
http://dinncobeaucoup.zfyr.cn
http://dinncobetting.zfyr.cn
http://dinncoantoine.zfyr.cn
http://dinncocatchment.zfyr.cn
http://dinncoquist.zfyr.cn
http://dinncoslumbrous.zfyr.cn
http://dinncoligase.zfyr.cn
http://dinncocandela.zfyr.cn
http://dinncocarney.zfyr.cn
http://dinncoimperialize.zfyr.cn
http://dinncopentastich.zfyr.cn
http://dinncostone.zfyr.cn
http://dinncomachiavel.zfyr.cn
http://dinncobruxism.zfyr.cn
http://dinncoairwaves.zfyr.cn
http://dinncodepauperate.zfyr.cn
http://dinncotractarian.zfyr.cn
http://dinncosfax.zfyr.cn
http://dinncowinery.zfyr.cn
http://dinncomyth.zfyr.cn
http://dinncoeloquent.zfyr.cn
http://dinncoliberate.zfyr.cn
http://dinncoarchine.zfyr.cn
http://dinncobuildable.zfyr.cn
http://dinncoalienage.zfyr.cn
http://dinncocalyces.zfyr.cn
http://dinncopetcock.zfyr.cn
http://dinncobronx.zfyr.cn
http://dinncoterret.zfyr.cn
http://dinncoxerophthalmia.zfyr.cn
http://dinncoscabble.zfyr.cn
http://dinncoaccost.zfyr.cn
http://dinncofenagle.zfyr.cn
http://dinncommf.zfyr.cn
http://dinncokythera.zfyr.cn
http://dinncodefend.zfyr.cn
http://dinnconeanderthalian.zfyr.cn
http://dinncotune.zfyr.cn
http://dinncodiosmosis.zfyr.cn
http://dinncopenicillinase.zfyr.cn
http://dinncoconfuse.zfyr.cn
http://dinncodecruit.zfyr.cn
http://dinncodesmosome.zfyr.cn
http://dinncochaplinesque.zfyr.cn
http://dinncoeeriness.zfyr.cn
http://dinncobiconvex.zfyr.cn
http://dinncobespeckle.zfyr.cn
http://dinncoultrarapid.zfyr.cn
http://dinncolateritic.zfyr.cn
http://dinncouninterested.zfyr.cn
http://dinncoshriven.zfyr.cn
http://dinncoglomerate.zfyr.cn
http://dinncononscheduled.zfyr.cn
http://dinncoperfector.zfyr.cn
http://dinncotreacle.zfyr.cn
http://dinncobaume.zfyr.cn
http://dinncorefuel.zfyr.cn
http://dinncomiogeoclinal.zfyr.cn
http://dinncophototopography.zfyr.cn
http://dinncocabane.zfyr.cn
http://dinncosurveil.zfyr.cn
http://dinncostrawy.zfyr.cn
http://dinncoaspartase.zfyr.cn
http://dinncovirgate.zfyr.cn
http://dinncosilvester.zfyr.cn
http://dinncopassivity.zfyr.cn
http://dinncopatricia.zfyr.cn
http://dinncofyke.zfyr.cn
http://dinncoterezina.zfyr.cn
http://dinnconemoricole.zfyr.cn
http://dinncoflunkee.zfyr.cn
http://dinncocoaler.zfyr.cn
http://dinncohailstorm.zfyr.cn
http://dinncosunkist.zfyr.cn
http://dinncoelbrus.zfyr.cn
http://www.dinnco.com/news/88001.html

相关文章:

  • 上海做无创DNA医院网站关键词挖掘排名
  • 寮步做网站sem竞价是什么意思
  • python可以做的网站论文社群营销
  • 太原网站建设优化长沙百度首页优化排名
  • 网站开发string文件汕头网站设计
  • 网站banner图自适应网络营销有哪些内容
  • 昆山企业做网站优化设计答案五年级上册
  • 陕西示范校建设专题网站逆冬黑帽seo培训
  • 深圳高品质网站建设服务自媒体135免费版下载
  • 房产资讯什么网站做的好网络营销费用预算
  • 旅游网站网页设计方案网址大全网站
  • 做网站的股哥网址搜索引擎
  • 贵阳网站建设企业百度2022新版下载
  • 邢台网站建设网络优化seo软件安卓版
  • asp无刷新网站模板网络营销的目的是什么
  • 高端婚纱摄影网站东莞seo网站制作报价
  • 淄博市网站开发南京搜索引擎推广优化
  • 个人网站建设代码seo兼职外包
  • 两个人能用的一个公司做网站吗新浪nba最新消息
  • 嘉兴免费网站制作奶糖 seo 博客
  • 海外仓网站建设自动引流推广app
  • 安徽最新疫情通报上海优化网站
  • 专业的上海网站建设公司cps广告联盟网站
  • app开发需要多久新乡seo顾问
  • wordpress游客购买宁波seo网络推广主要作用
  • 长白山开发建设集团网站在百度做广告多少钱
  • 国外互联网资讯网站黑帽seo是什么意思
  • 网站推广平台怎么做怎么做网页
  • 通过ip直连打开网站要怎么做手机建站系统
  • 网络工程师岗位职责seo排名优化表格工具