# Drawing a QRectangle in the Red, Green, or Yellow Slice View Windows

**URL:** https://discourse.slicer.org/t/drawing-a-qrectangle-in-the-red-green-or-yellow-slice-view-windows/29686
**Category:** Development
**Created:** [May 27, 2023, 3:45am UTC](https://discourse.slicer.org/t/drawing-a-qrectangle-in-the-red-green-or-yellow-slice-view-windows/29686 "2023-05-27T03:45:23Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![mikeT](https://avatars.discourse-cdn.com/v4/letter/m/9de053/32.png) [@mikeT](https://discourse.slicer.org/u/mikeT)
#### Post date: [May 27, 2023, 3:45am UTC](https://discourse.slicer.org/t/drawing-a-qrectangle-in-the-red-green-or-yellow-slice-view-windows/29686/1 "2023-05-27T03:45:23Z")

</div>

In my custom module, the user can adjust the size and position of the image capture of the RGY slice view windows. I would like to implement a button that will show the area to be captured by accessing the QPainter of the slice view window and then drawing a red rectangle in that window.

Here is an example of the script I have been trying to use:  
layoutManager = slicer.app.layoutManager()  
greenView = layoutManager.sliceWidget(‘Green’).sliceView()  
michelangelo = qt.QPainter(greenView)  
mPen=qt.QPen(qt.Qt.red)  
mPen.setWidth(5)  
michelangelo.setPen(mPen)  
michelangelo.drawRect(100,100,498,169)  
greenView.render()

Nothing shows up after running the code.

---

<div class="post-metadata">

### Author: ![lassoan](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/lassoan/32/13_2.png) [@lassoan](https://discourse.slicer.org/u/lassoan)
#### Post date: [May 28, 2023, 12:09pm UTC](https://discourse.slicer.org/t/drawing-a-qrectangle-in-the-red-green-or-yellow-slice-view-windows/29686/2 "2023-05-28T12:09:21Z")

</div>

I would recommend to draw a rectangle in a slice view using a markup ROI or plane instead.
