Skip to content

SizePolicyEdit

Qt Base Class: QWidget

Signature: QWidget(self, parent: Optional[PySide6.QtWidgets.QWidget] = None, f: PySide6.QtCore.Qt.WindowType = Default(Qt.WindowFlags)) -> None

Base classes

Name Children Inherits
Widget
prettyqt.widgets.widget

⋔ Inheritance diagram

graph TD
  1473367076496["custom_widgets.SizePolicyEdit"]
  1473293661888["widgets.Widget"]
  1473293688240["widgets.WidgetMixin"]
  1473299815024["core.ObjectMixin"]
  140713234304496["builtins.object"]
  1473245548480["gui.PaintDeviceMixin"]
  1473290849680["QtWidgets.QWidget"]
  1473288842240["QtCore.QObject"]
  1473291690208["Shiboken.Object"]
  1473300082368["QtGui.QPaintDevice"]
  1473293661888 --> 1473367076496
  1473293688240 --> 1473293661888
  1473299815024 --> 1473293688240
  140713234304496 --> 1473299815024
  1473245548480 --> 1473293688240
  140713234304496 --> 1473245548480
  1473290849680 --> 1473293661888
  1473288842240 --> 1473290849680
  1473291690208 --> 1473288842240
  140713234304496 --> 1473291690208
  1473300082368 --> 1473290849680
  1473291690208 --> 1473300082368

🛈 DocStrings

Bases: Widget

Source code in prettyqt\custom_widgets\editors\sizepolicyedit.py
class SizePolicyEdit(widgets.Widget):
    value_changed = core.Signal(widgets.QSizePolicy)

    def __init__(self, *args, object_name: str = "sizepolicy_edit", **kwargs):
        super().__init__(*args, object_name=object_name, **kwargs)
        self.set_margin(0)
        self.cb_horizontal = widgets.ComboBox()
        self.cb_vertical = widgets.ComboBox()
        self.cb_control_type = widgets.ComboBox()
        layout = self.set_layout("horizontal", margin=0)
        layout.add(widgets.Label("Horizontal:", alignment="center_right"))
        layout.add(self.cb_horizontal)
        layout.add(widgets.Label("Vertical:", alignment="center_right"))
        layout.add(self.cb_vertical)
        layout.add(widgets.Label("Control type:", alignment="center_right"))
        layout.add(self.cb_control_type)
        self.cb_vertical.add_items(widgets.sizepolicy.SIZE_POLICY.keys())
        self.cb_horizontal.add_items(widgets.sizepolicy.SIZE_POLICY.keys())
        self.cb_control_type.add_items(widgets.sizepolicy.CONTROL_TYPE.keys())
        self.cb_horizontal.value_changed.connect(self._on_value_change)
        self.cb_vertical.value_changed.connect(self._on_value_change)
        self.cb_control_type.value_changed.connect(self._on_value_change)

    def _on_value_change(self):
        self._value = self.get_value()
        self.value_changed.emit(self._value)

    def get_value(self) -> core.Point:
        policy = widgets.SizePolicy()
        policy.set_horizontal_policy(self.cb_horizontal.get_value())
        policy.set_vertical_policy(self.cb_vertical.get_value())
        policy.set_control_type(self.cb_control_type.get_value())
        return policy

    def set_value(self, value: widgets.QSizePolicy):
        self._value = value
        self.cb_horizontal.set_value(
            widgets.sizepolicy.SIZE_POLICY.inverse[value.horizontalPolicy()]
        )
        self.cb_vertical.set_value(
            widgets.sizepolicy.SIZE_POLICY.inverse[value.verticalPolicy()]
        )
        self.cb_control_type.set_value(
            widgets.sizepolicy.CONTROL_TYPE.inverse[value.controlType()]
        )

    value = core.Property(
        widgets.QSizePolicy,
        get_value,
        set_value,
        user=True,
        doc="Current value",
    )

⌗ Property table

Qt Property Type Doc
objectName QString
modal bool
windowModality Qt::WindowModality
enabled bool
geometry QRect
frameGeometry QRect
normalGeometry QRect
x int
y int
pos QPoint
frameSize QSize
size QSize
width int
height int
rect QRect
childrenRect QRect
childrenRegion QRegion
sizePolicy QSizePolicy
minimumSize QSize
maximumSize QSize
minimumWidth int
minimumHeight int
maximumWidth int
maximumHeight int
sizeIncrement QSize
baseSize QSize
palette QPalette
font QFont
cursor QCursor
mouseTracking bool
tabletTracking bool
isActiveWindow bool
focusPolicy Qt::FocusPolicy
focus bool
contextMenuPolicy Qt::ContextMenuPolicy
updatesEnabled bool
visible bool
minimized bool
maximized bool
fullScreen bool
sizeHint QSize
minimumSizeHint QSize
acceptDrops bool
windowTitle QString
windowIcon QIcon
windowIconText QString
windowOpacity double
windowModified bool
toolTip QString
toolTipDuration int
statusTip QString
whatsThis QString
accessibleName QString
accessibleDescription QString
layoutDirection Qt::LayoutDirection
autoFillBackground bool
styleSheet QString
locale QLocale
windowFilePath QString
inputMethodHints QFlags
value QSizePolicy Current value