[Qt-interest] MDI sub windows too small & setting widget bg image

John McClurkin jwm at nei.nih.gov
Mon Oct 18 20:25:47 CEST 2010


velociraptor Genjix wrote:
> Hello!
> I'm using MDI sub windows. On the sub windows is my custom widget. Unless I place a layout object and another widget inside it on my custom widget, then the mdi sub window will be -1,-1 eventhough the widget itself is (100,100) [you can see it by resizing the mdi sub window]
> class MdiTable(QtGui.QWidget):    sequenceNumber = 1
>     def __init__(self):        super(MdiTable, self).__init__()        self.resize(100,100)
>         b = QtGui.QTextEdit()
>         box = QtGui.QHBoxLayout()        box.addWidget(b)
>         self.setLayout(box)
> I'd rather just have my widget be a resizable size X, Y and place the widgets inside. How can I do this?

You have your custom widget and you place other widgets inside it. For 
sizing to work correctly, you need to have a layout in your widget and 
place the other widgets in the layout.

> Also how do I set a background image for the widget? This code doesn't work for me:
>         pix = QtGui.QPixmap('/images/carl_sagan.jpg')        p = QtGui.QPalette()        p.setBrush(QtGui.QPalette.Background, pix)        self.setPalette(p)
> Thanks! 		 	   		  



More information about the Qt-interest-old mailing list