Skip to content

Commit

Permalink
Merge pull request #7 from clci/accept-itemdatarole-and-flags
Browse files Browse the repository at this point in the history
Accept Qt.ItemDataRole, GraphicsItemFlag and QPainter.RenderHint
  • Loading branch information
bluebird75 authored Aug 24, 2023
2 parents b9fb6d9 + ea319e2 commit 232db47
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 6 deletions.
12 changes: 6 additions & 6 deletions PySide2-stubs/QtWidgets.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -3449,7 +3449,7 @@ class QGraphicsItem(Shiboken.Object):
def contains(self, point:PySide2.QtCore.QPointF) -> bool: ...
def contextMenuEvent(self, event:PySide2.QtWidgets.QGraphicsSceneContextMenuEvent) -> None: ...
def cursor(self) -> PySide2.QtGui.QCursor: ...
def data(self, key:int) -> typing.Any: ...
def data(self, key:typing.Union[int, PySide2.QtCore.Qt.ItemDataRole]) -> typing.Any: ...
def deviceTransform(self, viewportTransform:PySide2.QtGui.QTransform) -> PySide2.QtGui.QTransform: ...
def dragEnterEvent(self, event:PySide2.QtWidgets.QGraphicsSceneDragDropEvent) -> None: ...
def dragLeaveEvent(self, event:PySide2.QtWidgets.QGraphicsSceneDragDropEvent) -> None: ...
Expand Down Expand Up @@ -3638,11 +3638,11 @@ class QGraphicsItem(Shiboken.Object):
def setBoundingRegionGranularity(self, granularity:float) -> None: ...
def setCacheMode(self, mode:PySide2.QtWidgets.QGraphicsItem.CacheMode, cacheSize:PySide2.QtCore.QSize=...) -> None: ...
def setCursor(self, cursor: Union[PySide2.QtGui.QCursor, PySide2.QtCore.Qt.CursorShape]) -> None: ...
def setData(self, key:int, value:typing.Any) -> None: ...
def setData(self, key:typing.Union[int, PySide2.QtCore.Qt.ItemDataRole], value:typing.Any) -> None: ...
def setEnabled(self, enabled:bool) -> None: ...
def setFiltersChildEvents(self, enabled:bool) -> None: ...
def setFlag(self, flag:PySide2.QtWidgets.QGraphicsItem.GraphicsItemFlag, enabled:bool=...) -> None: ...
def setFlags(self, flags:PySide2.QtWidgets.QGraphicsItem.GraphicsItemFlags) -> None: ...
def setFlags(self, flags:PySide2.QtWidgets.QGraphicsItem.GraphicsItemFlags|PySide2.QtWidgets.QGraphicsItem.GraphicsItemFlag) -> None: ...
def setFocus(self, focusReason:PySide2.QtCore.Qt.FocusReason=...) -> None: ...
def setFocusProxy(self, item:PySide2.QtWidgets.QGraphicsItem) -> None: ...
def setGraphicsEffect(self, effect:PySide2.QtWidgets.QGraphicsEffect) -> None: ...
Expand Down Expand Up @@ -4765,7 +4765,7 @@ class QGraphicsView(PySide2.QtWidgets.QAbstractScrollArea):
def setOptimizationFlag(self, flag:PySide2.QtWidgets.QGraphicsView.OptimizationFlag, enabled:bool=...) -> None: ...
def setOptimizationFlags(self, flags:PySide2.QtWidgets.QGraphicsView.OptimizationFlags) -> None: ...
def setRenderHint(self, hint:PySide2.QtGui.QPainter.RenderHint, enabled:bool=...) -> None: ...
def setRenderHints(self, hints:PySide2.QtGui.QPainter.RenderHints) -> None: ...
def setRenderHints(self, hints:PySide2.QtGui.QPainter.RenderHints|PySide2.QtGui.QPainter.RenderHint) -> None: ...
def setResizeAnchor(self, anchor:PySide2.QtWidgets.QGraphicsView.ViewportAnchor) -> None: ...
def setRubberBandSelectionMode(self, mode:PySide2.QtCore.Qt.ItemSelectionMode) -> None: ...
def setScene(self, scene:PySide2.QtWidgets.QGraphicsScene) -> None: ...
Expand Down Expand Up @@ -5880,7 +5880,7 @@ class QListWidgetItem(Shiboken.Object):
def backgroundColor(self) -> PySide2.QtGui.QColor: ...
def checkState(self) -> PySide2.QtCore.Qt.CheckState: ...
def clone(self) -> PySide2.QtWidgets.QListWidgetItem: ...
def data(self, role:int) -> typing.Any: ...
def data(self, role:typing.Union[int, PySide2.QtCore.Qt.ItemDataRole]) -> typing.Any: ...
def flags(self) -> PySide2.QtCore.Qt.ItemFlags: ...
def font(self) -> PySide2.QtGui.QFont: ...
def foreground(self) -> PySide2.QtGui.QBrush: ...
Expand All @@ -5892,7 +5892,7 @@ class QListWidgetItem(Shiboken.Object):
def setBackground(self, brush: Union[PySide2.QtGui.QBrush, PySide2.QtGui.QColor]) -> None: ...
def setBackgroundColor(self, color: Union[PySide2.QtGui.QColor, PySide2.QtCore.Qt.GlobalColor, str, int]) -> None: ...
def setCheckState(self, state:PySide2.QtCore.Qt.CheckState) -> None: ...
def setData(self, role:int, value:typing.Any) -> None: ...
def setData(self, role:typing.Union[int, PySide2.QtCore.Qt.ItemDataRole], value:typing.Any) -> None: ...
def setFlags(self, flags:PySide2.QtCore.Qt.ItemFlags) -> None: ...
def setFont(self, font:PySide2.QtGui.QFont) -> None: ...
def setForeground(self, brush: Union[PySide2.QtGui.QBrush, PySide2.QtGui.QColor]) -> None: ...
Expand Down
11 changes: 11 additions & 0 deletions tests/qgraphicsitem.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
from PySide2.QtCore import Qt
from PySide2.QtWidgets import QGraphicsItem

class TestItem(QGraphicsItem):
pass

a = TestItem()
a.setData(Qt.UserRole, {1: 11, 2: 22})
_ = a.data(Qt.UserRole)

a.setFlags(QGraphicsItem.ItemSendsScenePositionChanges)
6 changes: 6 additions & 0 deletions tests/qgraphicsview.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
from PySide2.QtCore import Qt
from PySide2.QtGui import QPainter
from PySide2.QtWidgets import QGraphicsView

a = QGraphicsView()
a.setRenderHints(QPainter.Antialiasing)
7 changes: 7 additions & 0 deletions tests/qlistwidgetitem.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
from PySide2.QtCore import Qt
from PySide2.QtWidgets import QListWidgetItem

a = QListWidgetItem()
a.setData(Qt.UserRole, {1: 11, 2: 22})
_ = a.data(Qt.UserRole)

0 comments on commit 232db47

Please sign in to comment.