<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html; charset=ISO-8859-1"
http-equiv="Content-Type">
<title></title>
</head>
<body text="#000000" bgcolor="#ffffff">
Le 17/04/11 15:17, Sarah Mount a écrit :
<blockquote
cite="mid:BANLkTinHdkMRR2=QLO6JVBM7MrfWywEQzQ@mail.gmail.com"
type="cite">
<pre wrap="">Hi everyone,
I have a main application window that I want to style with a style
sheet like this:
#mywidget {
background : white;
background-image : url(:/images/images/EfDChancoComposite.jpg);
background-repeat : no-repeat;
}
When the project is created, the widget that I want to apply the CSS
to becomes an MDI area, so presumably the styling now needs to apply
to the MDI area, not the original widget, like this:
class MyMainWindow(QtGui.QMainWindow, Ui_MainWindow):
def __init__(self, parent=None):
QtGui.QMainWindow.__init__(self)
self.setupUi(self)
self.mdi = QtGui.QMdiArea()
self.mdi.setStyleSheet("QMdiArea { background : white;
background-image : url(:/images/images/EfDChancoComposite.jpg);
background-repeat : no-repeat; }")
self.setCentralWidget(self.mdi)
...but that doesn't work! Is this because QMdiArea widgets can't be
styled with CSS, and if so, is it possible to use a QBrush to do this
(including the no-repeat directive)? Or, have I just misunderstood the
API?
Many thanks,
Sarah
</pre>
</blockquote>
Hi,<br>
<br>
You can use setBackground()<br>
<br>
self.brush = QtGui.QBrush(QtGui.QPixmap("view.jpg"))<br>
self.mdi.setBackground(self.brush)<br>
<br>
but reimplement sizeEvent() for rescale the pixmap<br>
<br>
<div class="moz-signature">-- <br>
Vincent V.V.<br>
<a href="https://launchpad.net/oqapy">Oqapy</a></div>
</body>
</html>