forked from qt-creator/qt-creator
Doc: Update info on Qt for Python app wizards
Move the section higher up in "Creating projects" and add a screenshot of the wizard. Change-Id: Ifc48026162ff58d58ef22673d3113cb185d1c887 Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
This commit is contained in:
BIN
doc/images/qtcreator-python-wizard-app-window.png
Normal file
BIN
doc/images/qtcreator-python-wizard-app-window.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 16 KiB |
@@ -256,6 +256,8 @@
|
|||||||
For more information about creating Qt Quick projects, see
|
For more information about creating Qt Quick projects, see
|
||||||
\l {Creating Qt Quick Projects}.
|
\l {Creating Qt Quick Projects}.
|
||||||
|
|
||||||
|
\include creator-python-project.qdocinc python project wizards
|
||||||
|
|
||||||
\section1 Adding Files to Projects
|
\section1 Adding Files to Projects
|
||||||
|
|
||||||
You can use wizards also to add individual files to your projects.
|
You can use wizards also to add individual files to your projects.
|
||||||
@@ -408,8 +410,6 @@
|
|||||||
The above functions are also available in the context menu in the
|
The above functions are also available in the context menu in the
|
||||||
\uicontrol Projects view.
|
\uicontrol Projects view.
|
||||||
|
|
||||||
\include creator-python-project.qdocinc python project wizards
|
|
||||||
|
|
||||||
\section2 Creating OpenGL Fragment and Vertex Shaders
|
\section2 Creating OpenGL Fragment and Vertex Shaders
|
||||||
|
|
||||||
Qt provides support for integration with OpenGL implementations on all
|
Qt provides support for integration with OpenGL implementations on all
|
||||||
|
|||||||
@@ -42,22 +42,28 @@
|
|||||||
use \c {.pyqtc} files, but we recommend that you choose \c{.pyproject} files
|
use \c {.pyqtc} files, but we recommend that you choose \c{.pyproject} files
|
||||||
for new projects.
|
for new projects.
|
||||||
|
|
||||||
The Window wizard adds the following imports to the \c {main.py}
|
The \uicontrol {Qt for Python - Window} wizard enables you to create a
|
||||||
file to provide access to the QApplication and QMainWindow classes
|
Python source file for a new class that you can add to a Python project.
|
||||||
in the Qt Widgets module:
|
Specify the class name, base class, and and source file for the class.
|
||||||
|
|
||||||
|
\image qtcreator-python-wizard-app-window.png
|
||||||
|
|
||||||
|
The Window wizard adds the imports to the source file to provide
|
||||||
|
access to the QApplication and the base class you selected in the Qt
|
||||||
|
Widgets module:
|
||||||
|
|
||||||
\badcode
|
\badcode
|
||||||
import sys
|
import sys
|
||||||
from PySide2.QtWidgets import QApplication, QMainWindow
|
from PySide2.QtWidgets import QApplication, QWidget
|
||||||
\endcode
|
\endcode
|
||||||
|
|
||||||
The Window wizard also adds a \c MainWindow class that inherits from
|
The Window wizard also adds a main class with the specified name that
|
||||||
QMainWindow:
|
inherits from the specified base class:
|
||||||
|
|
||||||
\badcode
|
\badcode
|
||||||
class MainWindow(QMainWindow):
|
class MyWidget(QWidget):
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
QMainWindow.__init__(self)
|
QWidget.__init__(self)
|
||||||
\endcode
|
\endcode
|
||||||
|
|
||||||
Next, the Window wizard adds a main function, where it creates a
|
Next, the Window wizard adds a main function, where it creates a
|
||||||
@@ -68,13 +74,12 @@
|
|||||||
\badcode
|
\badcode
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
app = QApplication([])
|
app = QApplication([])
|
||||||
...
|
|
||||||
\endcode
|
\endcode
|
||||||
|
|
||||||
Next, the Window wizard instantiates the \c MainWindow class and shows it:
|
Next, the Window wizard instantiates the \c MainWindow class and shows it:
|
||||||
|
|
||||||
\badcode
|
\badcode
|
||||||
window = MainWindow()
|
window = MyWidget()
|
||||||
window.show()
|
window.show()
|
||||||
...
|
...
|
||||||
\endcode
|
\endcode
|
||||||
@@ -86,7 +91,7 @@
|
|||||||
sys.exit(app.exec_())
|
sys.exit(app.exec_())
|
||||||
\endcode
|
\endcode
|
||||||
|
|
||||||
The Empty wizard adds similar code to the \c {main.py} file, but it does
|
The Empty wizard adds similar code to the source file, but it does
|
||||||
not add any classes, so you need to add and instantiate them yourself.
|
not add any classes, so you need to add and instantiate them yourself.
|
||||||
|
|
||||||
For examples of creating Qt for Python applications, see
|
For examples of creating Qt for Python applications, see
|
||||||
|
|||||||
Reference in New Issue
Block a user