
- PyQt Tutorial
- PyQt - Home
- PyQt - Introduction
- PyQt - Environment
- PyQt - Hello World
- PyQt - Major Classes
- PyQt - Using Qt Designer
- PyQt - Meta Objects
- PyQt Signals & Slots
- PyQt - Signals and Slots
- PyQt - Support and Signals
- PyQt - Unbound and Bound Signals
- PyQt - New Signals with PyQtSignal
- PyQt - Connecting, Disconnecting, & Emitting Signals
- PyQt - Slot decorator
- PyQt - Slot Connection
- PyQt Layouts
- PyQt - Layout Management
- PyQt - QBoxLayout
- PyQt - QGridLayout
- PyQt - QFormLayout
- PyQt - QHBoxLayout
- PyQt - QVBoxLayout
- PyQt - QStackedLayout
- PyQt - QGraphicsGridLayout
- PyQt - QGraphicsAnchorLayout
- PyQt - QGraphicsLayout
- PyQt - QGraphicsLinearLayout
- PyQt Basic Widgets
- PyQt - Basic Widgets
- PyQt - Qlabel Widget
- PyQt - QLineEdit Widget
- PyQt - QPushButton Widget
- PyQt - QRadioButton Widget
- PyQt - QCheckBox Widget
- PyQt - QComboBox Widget
- PyQt - QSpinBox Widget
- PyQt - QMessageBox
- PyQt - QDialogButtonBox Widget
- PyQt - QFontComboBox Widget
- PyQt - QDoubleSpinBox Widget
- PyQt - QToolBox Widget
- PyQt - QMenuBar, QMenu & Qaction Widgets
- PyQt - QToolTip
- PyQt - QInputDialog Widget
- PyQt - QFontDialog Widget
- PyQt - QDialog Widget
- PyQt - QFileDialog Widget
- PyQt - QTab Widget
- PyQt - QSplitter Widget
- PyQt - QDock Widget
- PyQt - QStatusBar Widget
- PyQt - QTabBar
- PyQt - QList Widget
- PyQt - QScrollBar Widget
- PyQt - QProgressBar
- PyQt - QCalendar Widget
- PyQt - QMessageBox Widget
- PyQt - QPlainTextEdit
- PyQt - QDateEdit
- PyQt - QDateTimeEdit
- PyQt - QTimeEdit
- PyQt - QTextEdit
- PyQt - QTextBrowser
- PyQt - QScrollArea
- PyQt - Drag and Drop
- PyQt - Multiple Document Interface
- PyQt - QDialog Class
- PyQt Views
- PyQt - QColumnView
- PyQt - QTableView
- PyQt Drawing API
- PyQt - Drawing API
- PyQt - Drawing a Line
- PyQt - Drawing a Rectangle
- PyQt - Drawing a Triangle
- PyQt - Drawing a Circle
- PyQt - Drawing a Ellipse
- PyQt - Drawing a Polygon
- PyQt - Geometric Transformation
- PyQt - Drawing Effect
- PyQt Groups
- PyQt - QButtonGroup
- PyQt - QGroupBox
- PyQt Effects
- PyQt - Effects
- PyQt - Opacity Effect
- PyQt - QGraphicsBlur Effect
- PyQt - QGraphicsColorize Effect
- PyQt - QGraphicsDropShadow Effect
- PyQt Events
- PyQt - Event Handling
- PyQt - Drag & Drop Events
- PyQt - File Open Event
- PyQt - Action Event
- PyQt - Hide Event
- PyQt - Resize Event
- PyQt Database
- PyQt - Database Handling
- PyQt Essentials
- PyQt - BrushStyle Constants
- PyQt - QClipboard
- PyQt - QPixmap Class
- PyQt Useful Resources
- PyQt - Quick Guide
- PyQt - Useful Resources
- PyQt - Discussion
PyQt - Drawing a Circle
A circle is a two-dimentional rounded figure where all point lies inside a circumference. A circumference is defined as measuring distance around the outside edge of a circle. Its application uses in various field- graphics, architecture, landscaping, transportation, etc.

Drawing a Circle in PyQt
Circle is a geometrical concept which used in PyQt. The Widgets are parental root of any graphical user interface to draw the paintings. To draw a circle require multiple set of modules and built-in function that implement the specific tasks − color filled, border creation, plain shape, etc.
In this tutorial, we learn to draw different styles of circle in PyQt.
- Dotted Circle − A Dotted Circle is a combination of multiple dots to draw a circle. Constructing a dotted shape uses three sets of parameters as integer precision. The first two sets are known for positioning and the other is diameter.
- Plain Shape − A plain shape represent the simple shape of circle. This can be drawn using the method SimpleCircle(). This function accept three set of integer as parmeters- the first two parameter set as positioning and other is diameter.
- Color Filled Circle − A circle filled with a background is called color filled circle. This can be drawn using the method FilledCircle.
- Half Circle − The Half circle comparatively similar to the shape of an arc. Therefore, we use drawArc()function to display the half circle.
Example 1
Following example illutrates the code snippet of dotted circle using PyQt. Here, we use the class QPen that set the parameter as Qt.PenStyle.DotLine to create a styling effect(dot).
import sys from PyQt6.QtWidgets import QGraphicsScene, QGraphicsView, QGraphicsEllipseItem, QApplication from PyQt6.QtCore import Qt from PyQt6.QtGui import QPen, QColor # Custom QGraphicsEllipseItem for a dotted circle class DottedCircle(QGraphicsEllipseItem): def __init__(self, x, y, diameter): super(DottedCircle, self).__init__(x, y, diameter, diameter) # Set the pen style to create a dotted circle pen = QPen(Qt.PenStyle.DotLine) self.setPen(pen) # Custom QGraphicsScene class MyScene(QGraphicsScene): def __init__(self): super(MyScene, self).__init__() # Create a dotted circle at position (50, 50) with a diameter of 100 dotted_circle = DottedCircle(50, 50, 100) # Add the circle to the scene self.addItem(dotted_circle) def main(): app = QApplication(sys.argv) # Create a QGraphicsView view = QGraphicsView() # Create an instance of MyScene scene = MyScene() # Set the scene for the view view.setScene(scene) # Show the view view.show() # Execute the application sys.exit(app.exec()) if __name__ == '__main__': main()
Output
The above code produces the following output −

Example 2
Following example illustrate the code snippet of Plain Circle in PyQt.
import sys from PyQt6.QtWidgets import QGraphicsScene, QGraphicsView, QGraphicsEllipseItem, QApplication from PyQt6.QtCore import Qt class SimpleCircle(QGraphicsEllipseItem): def __init__(self, x, y, diameter): super(SimpleCircle, self).__init__(x, y, diameter, diameter) class MyScene(QGraphicsScene): def __init__(self): super(MyScene, self).__init__() # Create a simple circle at position (50, 50) with a diameter of 100 simple_circle = SimpleCircle(50, 50, 100) # Add the circle to the scene self.addItem(simple_circle) def main(): app = QApplication(sys.argv) # Create a QGraphicsView view = QGraphicsView() # Create an instance of MyScene scene = MyScene() # Set the scene for the view view.setScene(scene) # Show the view view.show() # Execute the application sys.exit(app.exec()) if __name__ == '__main__': main()
Output
The above code produces the following output −

Example 3
Following example illustrate the code snippet of color filled circle using PyQt. Here, we apply the method FilledCircle() that used to specify the points with a color value.
import sys from PyQt6.QtWidgets import QGraphicsScene, QGraphicsView, QGraphicsEllipseItem, QApplication from PyQt6.QtGui import QBrush, QColor class FilledCircle(QGraphicsEllipseItem): def __init__(self, x, y, diameter, color): super(FilledCircle, self).__init__(x, y, diameter, diameter) # Create a QBrush with the specified color brush = QBrush(QColor(color)) self.setBrush(brush) class MyScene(QGraphicsScene): def __init__(self): super(MyScene, self).__init__() # Create a filled circle at position (50, 50) with a diameter of 100 and red color # Specify color using hexadecimal RGB value filled_circle = FilledCircle(50, 50, 100, "#FF0000") # Add the filled circle to the scene self.addItem(filled_circle) def main(): app = QApplication(sys.argv) # Create a QGraphicsView view = QGraphicsView() # Create an instance of MyScene scene = MyScene() # Set the scene for the view view.setScene(scene) # Show the view view.show() # Execute the application sys.exit(app.exec()) if __name__ == '__main__': main()
Output
The above code produces the following output −

Example 4
Following example illustrate the code of half circle using PyQt.
from PyQt6 import QtWidgets, QtGui, QtCore from PyQt6.QtGui import QPainter class MyWidget(QtWidgets.QWidget): def paintEvent(self, event): painter = QPainter(self) painter.setRenderHint(QtGui.QPainter.RenderHint.Antialiasing) painter.setPen(QtCore.Qt.GlobalColor.black) painter.setBrush(QtCore.Qt.GlobalColor.white) painter.drawArc(110, 80, 310, 310, 0 * 26, 100 * 26) app = QtWidgets.QApplication([]) widget = MyWidget() widget.show() app.exec()
Output
The above code produces the following output −
