|Hi all,
I am having difficulties with something I thought was going to be simple:
I've got a custom button widget that uses it's own paint() function. I then
place multiple instances of this in a QGrisLayout.
The problem is that the layout's spacing doesn't effect the custom button when
the paint() function is re-implemented.
I am filling self.rect() with the background color which might be the problem?
Here is an example that probably shows better what I'm after. The QPushButtons
have the layout's spacing in between each instance while the custom buttons
don't.
I'm sure it's blatantly obvious what I'm doing wrong here, but I can't spot it.
Any help would be great!
Cheers,
frank
import sys
from PySide.QtGui import *
from PySide.QtCore import *
class CustomButton(QPushButton):
def __init__(self, tool, icon=None, parent=None):
super(CustomButton, self).__init__(parent)
self.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Fixed)
self.setMinimumWidth(200)
self.frameGeometry()
def paintEvent(self, event):
painter= QPainter(self)
bgColor= QColor(60, 60, 60)
painter.fillRect(self.rect(), bgColor)
app= QApplication(sys.argv)
mainWindow= QWidget()
grid= QGridLayout()
grid.setSpacing(10)
mainWindow.setLayout(grid)
for iin xrange(4):
btn1= CustomButton('A')
btn2= QPushButton('B')
grid.addWidget(btn1, 0, i)
grid.addWidget(btn2, 1, i)
|
_______________________________________________
PySide mailing list
[email protected]
http://lists.qt-project.org/mailman/listinfo/pyside