en:qt
Unterschiede
Hier werden die Unterschiede zwischen zwei Versionen angezeigt.
Beide Seiten der vorigen RevisionVorhergehende ÜberarbeitungNächste Überarbeitung | Vorhergehende Überarbeitung | ||
en:qt [2022/08/24 16:56] – [Button] roehner | en:qt [2024/05/07 17:09] (aktuell) – roehner | ||
---|---|---|---|
Zeile 1: | Zeile 1: | ||
===== Precondition ===== | ===== Precondition ===== | ||
- | To use the modern and powerful Qt library, you need to install the PyQt6 package. To do this, call up the command | + | To use the modern and powerful Qt library, you need to install the PyQt6 package. To do this, call up the command // |
- | Alternatively, you can install the PySide6 package and replace PyQt6 with PySide6 in the Qt template. The Qt template can be found in the configuration under Editor/File templates. | + | In addition, you should |
+ | |||
+ | One of the major changes in PyQt6 is the need to use fully qualified names for enums and flags. For example in PyQt5 and PySide2 you could just write Qt.DecorationRole or Qt.AlignLeft. This shortened form no longer works in PyQt6, you now have to write Qt.ItemDataRole.DisplayRole or Qt.Alignment.AlignLeft. This change affects all enums and flag types in Qt. Both long and short names are still supported in PySide6. | ||
+ | |||
+ | If you prefer to work with the shortened forms, you can replace PyQt6 with PySide6 in the Qt template. The Qt template can be found in the configuration under Editor/File templates. | ||
Detailed information about Qt can be found in the [[https:// | Detailed information about Qt can be found in the [[https:// | ||
Zeile 14: | Zeile 18: | ||
The Python code of a GUI program is saved with the .pyw file extension, the associated form with the .pfm file extension. Both will open together. If you close the form, you can open it again using the {{: | The Python code of a GUI program is saved with the .pyw file extension, the associated form with the .pfm file extension. Both will open together. If you close the form, you can open it again using the {{: | ||
+ | ===== Qt Base ===== | ||
==== Label ==== | ==== Label ==== | ||
{{: | {{: | ||
Zeile 69: | Zeile 74: | ||
==== CheckBox ==== | ==== CheckBox ==== | ||
{{: | {{: | ||
- | A CheckBox may or may not be selected. The boolean method // | + | A CheckBox may or may not be selected. The boolean method // |
Example: | Example: | ||
Zeile 136: | Zeile 141: | ||
A ScrollBar can be used to scroll, in which the visible section of a displayed text or graphic is moved. Some widgets such as B. PlainTextEdit, | A ScrollBar can be used to scroll, in which the visible section of a displayed text or graphic is moved. Some widgets such as B. PlainTextEdit, | ||
+ | ---- | ||
+ | ==== Canvas ==== | ||
+ | {{: | ||
+ | A Canvas is a drawing surface. The Painter for the canvas has many drawing possibilities. | ||
+ | |||
+ | Example: | ||
+ | <code python> | ||
+ | def pushButton1_clicked(self, | ||
+ | self.canvas1Painter.drawEllipse(0, | ||
+ | self.canvas1Painter.drawLine(0, | ||
+ | self.canvas1.setPixmap(self.canvas1Pixmap) | ||
+ | </ | ||
+ | |||
+ | A Canvas consists of a Label widget that hosts the canvas. Then we have a pixmap the size of the Label, which is the actual drawing surface. And third, we have the QPainter that draws on the pixmap. | ||
+ | |||
+ | A shown in the example, you can easily draw on the canvas with the painter. When the drawing is finished, you have to show it with | ||
+ | <code python> | ||
---- | ---- | ||
==== Frame ==== | ==== Frame ==== | ||
Zeile 141: | Zeile 163: | ||
A Frame wigdet is a container for other widgets. Frames are a good way to structure graphic interfaces. To place a widget in a frame, click it in the toolbar and then click in the frame, or drag and drop a widget from the toolbar over the frame. If you move a frame, the widgets it contains are also moved. | A Frame wigdet is a container for other widgets. Frames are a good way to structure graphic interfaces. To place a widget in a frame, click it in the toolbar and then click in the frame, or drag and drop a widget from the toolbar over the frame. If you move a frame, the widgets it contains are also moved. | ||
---- | ---- | ||
- | ==== LabelFrame | + | ==== GroupBox |
{{: | {{: | ||
Like a Frame widget, a GroupBox is a container for other widgets. A GroupBox also has a frame with an integrated label. | Like a Frame widget, a GroupBox is a container for other widgets. A GroupBox also has a frame with an integrated label. | ||
- | GuiPy graphically displays a ButtonGroup for RadioButtons using a GroupBox. | + | GuiPy graphically displays a ButtonGroup for RadioButtons |
---- | ---- | ||
==== Slider==== | ==== Slider==== | ||
Zeile 189: | Zeile 211: | ||
A Menu widget is a context menu that is invoked with the right mouse button. As with the MenuBar widget, it is defined using the // | A Menu widget is a context menu that is invoked with the right mouse button. As with the MenuBar widget, it is defined using the // | ||
- | You can assign a context menu to each widget. To do this, you specify the name of the context | + | You can assign a context menu to each widget. To do this, you specify the name of the menu in the // |
---- | ---- | ||
==== TabWidget ==== | ==== TabWidget ==== | ||
Zeile 224: | Zeile 246: | ||
{{: | {{: | ||
---- | ---- | ||
+ | ===== Qt Controls ===== | ||
==== TextEdit ==== | ==== TextEdit ==== | ||
{{: | {{: |
en/qt.1661352970.txt.gz · Zuletzt geändert: 2022/08/24 16:56 von roehner