from PyQt5.QtCore import QPointF # creating a point at (10, 20) point = QPointF(10, 20) # get the x and y coordinates x = point.x() y = point.y() print(f"Point coordinates: ({x}, {y})")
from PyQt5.QtCore import QPointF # creating two points point1 = QPointF(10, 20) point2 = QPointF(30, 40) # calculating the distance between the points using the Pythagorean theorem dx = point1.x() - point2.x() dy = point1.y() - point2.y() distance = (dx ** 2 + dy ** 2) ** 0.5 print(f"Distance between points: {distance}")This code creates two QPointF objects and calculates the distance between them using the Pythagorean theorem. Package Library: PyQt5.QtCore is part of the PyQt5 package, a set of Python bindings for Qt. Qt is a cross-platform application framework that allows developers to create graphical user interfaces for desktop, mobile, and embedded devices. PyQt5 provides access to the entire Qt API, including modules for graphics, multimedia, network, and more.