PyQt - Draw rectangle behind a widget
<p>I have a QStackedWidget with a QLineEdit and a couple other widgets inside of it. This QStackedWidget is fairly dynamic - you can move it within its layout by clicking/dragging, change its current widget by right clicking it, etc.</p>

<p>I'd like to draw a simple, gray rectangle or a gray rounded rectangle around the QStackedWidget to let people know that the QLineEdit they're looking at is important. This drawn rectangle has to be able to follow the QStackedWidget so that it follows properly with the widget when I move it to other locations on-screen.</p>

<p>I've tried several approaches so far but they've all fallen short in some regard or another or it just wouldn't move with the widget. Can anyone show me how?</p>

<p>Depending on how your clicking/dragging is implemented, you should just be able to place the <code>QStackedWidget</code> inside another <code>QFrame</code>, or put a <code>QFrame</code> inside your <code>QStackedWidget</code> and put all the other controls inside the <code>QFrame</code>.  <code>QFrame</code>'s support drawing borders around them.</p>

<pre><code>frame = QFrame()
frame.setFrameStyle(QFrame.StyledPanel)
frame.setLineWidth(2)
</code></pre>

python pyqt draw