4. Display Widgets
Display widgets are read-only widgets used to provide information to the user. They include
Qlabelfor text, images, and animations,QProgressBarfor showing task progress,QLCDNumberfor displaying number in an LCD-style,QTextBrowserfor read-only rich text with hyperlink support.
4.1 Displaying Text with QLabel
QLabel supports three text formats: plain text, Markdown, and rich text (rendered using a subset of HTML). The format is controlled via setTextFormat(). Available constants are:
| Value | Enum Constant | Description |
|---|---|---|
| 0 | Qt::PlainText |
Plain text |
| 1 | Qt::RichText |
Qt-supported HTML subset |
| 2 | Qt::AutoText |
Format automatically detected (default) |
| 3 | Qt::MarkdownText |
Markdown formatting |
![]() |
To display text using |
-
Create a
QLabelobject, setting its text. We create three labels:- one with plain text (no formatting),
- one with Markdown syntax,
- one with HTML syntax.
-
Set the text format for the Markdown and rich-text labels using
setTextFormat():Qt.TextFormat.MarkdownTextfor the Markdown text,Qt.TextFormat.RichTextfor the rich-text label.
Add the label(s) to the layout and display the window. When the window is shown, the Markdown and rich-text labels will display bold text.
When you run the application you should see a window like this:

4.2 Displaying Images with Qlabel
QLabel can display static images, vector graphics, and animated GIFs using the following methods:
| Method | Description |
|---|---|
setPixmap() |
Displays a static image from a QPixmap |
setPicture() |
Displays a vector graphic from a QPicture |
setMovie() |
Displays an animated GIF or movie from a QMovie |
![]() |
To display an image in a label: |
Create an image object. We create two pictures: a png image using
QPixmapand an animated gif image usingQMovie,Create label objects that will display the images.
Set the labels’ contents to the png and the gif images.
The running application should look like this:

4.3 Displaying LCD-like Numbers with QLCDNumber
As the documentation states, QLCDNumber is the very oldest part of Qt, tracing its roots back to a BASIC program on the Sinclair Spectrum.
![]() |
To use it in your application: |
Create a
QLCDNumberinstance,Set its digit count,
Set the number to display using
QLCDNumber.display()
When you start the application, you should see this:

You are not restricted to QLabel for images - any widget can draw images by reimplementing its paintEvent() method, giving you full control over rendering.
