I read qlineedit.cpp, as you wisely suggest. Doing this gave me the inspiration
for this solution (python code):
def __init__(self, parent=None):
super(MyWidget, self).__init__(parent)
qle.initStyleOption(self.styleoption)
def paintEvent(self, event):
self.styleoption.rect = self.contentsRect()
self.
style().
drawPrimitive(QStyle.
PE_PanelLineEdit, self.
styleoption, painter
)
class MyWidget(QWidget):
def __init__(self, parent=None):
super(MyWidget, self).__init__(parent)
self.styleoption = QStyleOptionFrameV2()
qle = QLineEdit()
qle.initStyleOption(self.styleoption)
def paintEvent(self, event):
painter = QPainter(self)
self.styleoption.rect = self.contentsRect()
self.style().drawPrimitive(QStyle.PE_PanelLineEdit, self.styleoption, painter)
To copy to clipboard, switch view to plain text mode
In other words, I use a QLineEdit to fill in the QStyleOption object for me.
Then I can use drawPrimitive (borisbn's hint) to have my widget drawn as
I like.
Thank you for you patience, I learned some useful things.
Bookmarks