Trolltech Home | Qt-interest Home | Recent Threads | All Threads | Author | Date
All threads index page 2

Qt-interest Archive, September 2007
Re: what is the equivalent of Qt3 setPaletteBackgroundPixmap in Qt4


Message 1 in thread

Was there an answer for this question?

On Friday 31 August 2007 20:25:04 Joachim Schmitz wrote:
> Hi,
>
> I have an application written in PyQt3 which uses the following code to
> set a background-pixmap for a widget.
>
> bgpixmap = QPixmap(aus_gr_px*3*scale,aus_gr_px*3*scale)
> bgp = QPainter(bgpixmap)
> offset_px_x = 10
> offset_px_y = 10
> r y in range(3):
>      for x in range(3):
>          dx= top_left.x() + x*offset_px_x
>          dy= top_left.y() + y*offset_px_y
>          p = QPixmap()
>          p.convertFromImage(image.copy(QRect(QPoint(dx,dy),rsize)))
>          px = x * 30
>          py = y * 30
>          point = QPoint(px,py)
>          rd = {}
>          rd['position'] = QPoint(dx,dy) - top_left
>          rd['rect'] = QRect(point,QSize(aus_gr_px,aus_gr_px))
>          self.rects.append(rd)
>          bgp.drawPixmap(point,p)
> self.setPaletteBackgroundPixmap(bgpixmap)
>
> What this does is draw the bgppixmap and set it as a background for the
> current widget.
>
>
> In qt4 the setPaletteBackgroundPixmap is only available in Q3Widget,
> which is not available for PyQt4. So my question is, how to do this in Qt4
> ?


--
 [ signature omitted ] 

Message 2 in thread

Qt Assistant says:

"void QWidget::setPaletteBackgroundPixmap ( const QPixmap & pixmap )

Use the palette directly.

For example, if you have code like

 widget->setPaletteBackgroundPixmap(pixmap);

you can rewrite it as

 QPalette palette;
 palette.setBrush(widget->backgroundRole(), QBrush(pixmap));
 widget->setPalette(palette);"

I hope this helps.

- Thomas


2007/9/9, J. Preiss <auba@xxxxxxx>:
> Was there an answer for this question?
>
> On Friday 31 August 2007 20:25:04 Joachim Schmitz wrote:
> > Hi,
> >
> > I have an application written in PyQt3 which uses the following code to
> > set a background-pixmap for a widget.
> >
> > bgpixmap = QPixmap(aus_gr_px*3*scale,aus_gr_px*3*scale)
> > bgp = QPainter(bgpixmap)
> > offset_px_x = 10
> > offset_px_y = 10
> > r y in range(3):
> >      for x in range(3):
> >          dx= top_left.x() + x*offset_px_x
> >          dy= top_left.y() + y*offset_px_y
> >          p = QPixmap()
> >          p.convertFromImage(image.copy(QRect(QPoint(dx,dy),rsize)))
> >          px = x * 30
> >          py = y * 30
> >          point = QPoint(px,py)
> >          rd = {}
> >          rd['position'] = QPoint(dx,dy) - top_left
> >          rd['rect'] = QRect(point,QSize(aus_gr_px,aus_gr_px))
> >          self.rects.append(rd)
> >          bgp.drawPixmap(point,p)
> > self.setPaletteBackgroundPixmap(bgpixmap)
> >
> > What this does is draw the bgppixmap and set it as a background for the
> > current widget.
> >
> >
> > In qt4 the setPaletteBackgroundPixmap is only available in Q3Widget,
> > which is not available for PyQt4. So my question is, how to do this in Qt4
> > ?
>
>
> --
> To unsubscribe - send a mail to qt-interest-request@xxxxxxxxxxxxx with "unsubscribe" in the subject or the body.
> List archive and information: http://lists.trolltech.com/qt-interest/
>
>

--
 [ signature omitted ]