aboutsummaryrefslogtreecommitdiffstats
path: root/doc/src/python/creator-python-project.qdocinc
diff options
context:
space:
mode:
authorLeena Miettinen <riitta-leena.miettinen@qt.io>2019-03-21 13:31:32 +0100
committerLeena Miettinen <riitta-leena.miettinen@qt.io>2019-04-01 09:06:17 +0000
commit8fe6d2181ee375e4390197841392a223b516e209 (patch)
tree8857b33c0285e63dd96dccf31a86fd624e65eb8a /doc/src/python/creator-python-project.qdocinc
parentfeca64ee9d9a042ddb1ae270bce63cdfb6b852bd (diff)
Doc: Describe the Qt for Python project wizards
Explain the code generated by the wizards. Change-Id: I07a172d57710b1c50d77b2a7552a3686a4607af4 Reviewed-by: Venugopal Shivashankar <Venugopal.Shivashankar@qt.io> Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io> Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
Diffstat (limited to 'doc/src/python/creator-python-project.qdocinc')
-rw-r--r--doc/src/python/creator-python-project.qdocinc97
1 files changed, 97 insertions, 0 deletions
diff --git a/doc/src/python/creator-python-project.qdocinc b/doc/src/python/creator-python-project.qdocinc
new file mode 100644
index 0000000000..fdb58155a6
--- /dev/null
+++ b/doc/src/python/creator-python-project.qdocinc
@@ -0,0 +1,97 @@
+/****************************************************************************
+**
+** Copyright (C) 2019 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the Qt Creator documentation.
+**
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU Free Documentation License Usage
+** Alternatively, this file may be used under the terms of the GNU Free
+** Documentation License version 1.3 as published by the Free Software
+** Foundation and appearing in the file included in the packaging of
+** this file. Please review the following information to ensure
+** the GNU Free Documentation License version 1.3 requirements
+** will be met: https://www.gnu.org/licenses/fdl-1.3.html.
+**
+****************************************************************************/
+
+/*!
+//! [python project wizards]
+
+ \section2 Creating Qt for Python Applications
+
+ \l {https://doc.qt.io/qtforpython/index.html}{Qt for Python} enables you
+ to use Qt 5 API in Python applications. You can use the PySide2 module to
+ gain access to individual Qt modules, such as \l {Qt Core}, \l {Qt GUI},
+ and \l {Qt Widgets}.
+
+ The Qt for Python Application wizards generate a \c {.pyproject} file that
+ lists the files in the Python project and a \c {.py} file that contains
+ some boilerplate code.
+
+ The \c{.pyproject} files are JSON-based configuration files that replace
+ the previously used \c {.pyqtc} configuration files. You can still open and
+ use \c {.pyqtc} files, but we recommend that you choose \c{.pyproject} files
+ for new projects.
+
+ The Window wizard adds the following imports to the \c {main.py}
+ file to provide access to the QApplication and QMainWindow classes
+ in the Qt Widgets module:
+
+ \badcode
+ import sys
+ from PySide2.QtWidgets import QApplication, QMainWindow
+ \endcode
+
+ The Window wizard also adds a \c MainWindow class that inherits from
+ QMainWindow:
+
+ \badcode
+ class MainWindow(QMainWindow):
+ def __init__(self):
+ QMainWindow.__init__(self)
+ \endcode
+
+ Next, the Window wizard adds a main function, where it creates a
+ QApplication instance. As Qt can receive arguments from the command line,
+ you can pass any arguments to the QApplication object. Usually, you do not
+ need to pass any arguments, and you can use the following approach:
+
+ \badcode
+ if __name__ == "__main__":
+ app = QApplication([])
+ ...
+ \endcode
+
+ Next, the Window wizard instantiates the \c MainWindow class and shows it:
+
+ \badcode
+ window = MainWindow()
+ window.show()
+ ...
+ \endcode
+
+ Finally, the Window wizard calls the \c app.exec_() method to enter the Qt
+ main loop and start executing the Qt code:
+
+ \badcode
+ sys.exit(app.exec_())
+ \endcode
+
+ The Empty wizard adds similar code to the \c {main.py} file, but it does
+ not add any classes, so you need to add and instantiate them yourself.
+
+ For examples of creating Qt for Python applications, see
+ \l {https://doc.qt.io/qtforpython/tutorials/index.html}
+ {Qt for Python Examples and Tutorials}.
+
+//! [python project wizards]
+*/