[PyQt] Widget border and focus
russ at coldstonelabs.org
Wed Feb 24 03:47:48 GMT 2010
I'm wondering if anyone has tried to make a custom widget and wanted a
border around your widget (sunken or otherwise) like all the other
widgets have. It then also gets highlighted when it has focus. I thought
that it was QFrame that is doing that, but by putting my custom widget
in a QFrame, nothing happens, even if I manually set the frame style.
Below is some simple code. I have a splitter, on one side is my custom
widget and on the other side is a QListView. You can see the border
around the QListView and when it has focus the border changes to
indicate it. You can not tell the customwidget has focus however.
I've been trying to figure this out for a couple of days now, and
haven't found a solution yet. I think I'm missing some simple concept.
If anyone can point me in the right direction I would appreciate it.
from PyQt4 import QtGui, QtCore
def __init__(self, parent):
def paintEvent(self, event):
painter.fillRect(0, 0, self.width(), self.height(), b)
def __init__(self, app):
self.customWidget = CustomWidget(self)
self.list = QtGui.QListView()
if __name__ == "__main__":
window = MainWindow(app)
More information about the PyQt