aboutsummaryrefslogtreecommitdiffstats
path: root/sources/pyside6/doc/tutorials/basictutorial/widgets.rst
diff options
context:
space:
mode:
authorFriedemann Kleint <Friedemann.Kleint@qt.io>2020-11-02 16:11:52 +0100
committerFriedemann Kleint <Friedemann.Kleint@qt.io>2020-11-02 16:12:04 +0000
commit25180730194bec25f915f32ab846ea583fb1493f (patch)
tree9a73e0336ecf21e085d99d6a651c5547b9eb99f8 /sources/pyside6/doc/tutorials/basictutorial/widgets.rst
parent6e3e7b9ca0548430aaa5e2555d6e02c64625fa3f (diff)
Rename PySide2 to PySide6
Adapt CMake files, build scripts, tests and examples. Task-number: PYSIDE-904 Change-Id: I845f7b006e9ad274fed5444ec4c1f9dbe176ff88 Reviewed-by: Christian Tismer <tismer@stackless.com>
Diffstat (limited to 'sources/pyside6/doc/tutorials/basictutorial/widgets.rst')
-rw-r--r--sources/pyside6/doc/tutorials/basictutorial/widgets.rst45
1 files changed, 45 insertions, 0 deletions
diff --git a/sources/pyside6/doc/tutorials/basictutorial/widgets.rst b/sources/pyside6/doc/tutorials/basictutorial/widgets.rst
new file mode 100644
index 000000000..d86ba2623
--- /dev/null
+++ b/sources/pyside6/doc/tutorials/basictutorial/widgets.rst
@@ -0,0 +1,45 @@
+Your First QtWidgets Application
+*********************************
+
+As with any other programming framework,
+you start with the traditional "Hello World" program.
+
+Here is a simple example of a Hello World application in PySide6:
+
+.. code-block:: python
+
+ import sys
+ from PySide6.QtWidgets import QApplication, QLabel
+
+ app = QApplication(sys.argv)
+ label = QLabel("Hello World!")
+ label.show()
+ app.exec_()
+
+
+For a widget application using PySide6, you must always start by
+importing the appropriate class from the `PySide6.QtWidgets` module.
+
+After the imports, you create a `QApplication` instance. As Qt can
+receive arguments from command line, you may pass any argument to
+the QApplication object. Usually, you don't need to pass any
+arguments so you can leave it as is, or use the following approach:
+
+.. code-block:: python
+
+ app = QApplication([])
+
+After the creation of the application object, we have created a
+`QLabel` object. A `QLabel` is a widget that can present text
+(simple or rich, like html), and images:
+
+.. code-block:: python
+
+ # This HTML approach will be valid too!
+ label = QLabel("<font color=red size=40>Hello World!</font>")
+
+.. note:: After creating the label, we call `show()` on it.
+
+Finally, we call `app.exec_()` to enter the Qt main loop and start
+to execute the Qt code. In reality, it is only here where the label
+is shown, but this can be ignored for now.