class_docstr: **Bases:** :class:`GraphicsObject <pyqtgraph.GraphicsObject>`
class_docstr_tok: ["*","*","Bases",":","*","*",":","class",":","`","GraphicsObject","<","pyqtgraph.GraphicsObject",">","`"]
docstr: setRect(rect) or setRect(x,y,w,h)
  
  Sets translation and scaling of this ImageItem to display the current image within the rectangle given
  as ``rect`` (:class:`QtCore.QRect` or :class:`QtCore.QRectF`), or described by parameters `x, y, w, h`, 
  defining starting position, width and height.
  
  This method cannot be used before an image is assigned.
  See the :ref:`examples <ImageItem_examples>` for how to manually set transformations.
docstr_tok: ["setRect","(","rect",")","or","setRect","(","x",",","y",",","w",",","h",")","Sets","translation","and","scaling","of","this","ImageItem","to","display","the","current","image","within","the","rectangle","given","as","``","rect","``","(",":","class",":","`","QtCore.QRect","`","or",":","class",":","`","QtCore.QRectF","`",")",",","or","described","by","parameters","`","x",",","y",",","w",",","h","`",",","defining","starting","position",",","width","and","height",".","This","method","can","not","be","used","before","an","image","is","assigned",".","See","the",":","ref",":","`","examples","<","ImageItem_examples",">","`","for","how","to","manually","set","transformations","."]
code: def setRect(self, *args):
      """
      setRect(rect) or setRect(x,y,w,h)
  
      Sets translation and scaling of this ImageItem to display the current image within the rectangle given
      as ``rect`` (:class:`QtCore.QRect` or :class:`QtCore.QRectF`), or described by parameters `x, y, w, h`,
      defining starting position, width and height.
  
      This method cannot be used before an image is assigned.
      See the :ref:`examples <ImageItem_examples>` for how to manually set transformations.
      """
      if len(args) == 0:
          self.resetTransform()  # reset scaling and rotation when called without argument
          return
      if isinstance(args[0], (QtCore.QRectF, QtCore.QRect)):
          rect = args[0]  # use QRectF or QRect directly
      else:
          if hasattr(args[0], "__len__"):
              args = args[0]  # promote tuple or list of values
          rect = QtCore.QRectF(
              *args
          )  # QRectF(x,y,w,h), but also accepts other initializers
      tr = QtGui.QTransform()
      tr.translate(rect.left(), rect.top())
      tr.scale(
          rect.width() / self.width(), rect.height() / self.height()
      )
      self.setTransform(tr)
  
imports: import warnings
  from collections.abc import Callable
  import numpy
  from ..None import colormap
  from ..None import debug
  from ..None import functions
  from ..None import getConfigOption
  from ..Point import Point
  from ..Qt import QtCore, QtGui, QtWidgets
  from ..util.cupy_helper import getCupy
  from .GraphicsObject import GraphicsObject
label_desc: Use image node_id 16 for calling the ImageItem obj's underlying member method code with example usage: obj.setRect() without return types