| Trolltech Home | Qt-interest Home | Recent Threads | All Threads | Author | Date | |
| All threads index page 1 | |
Thanks for your answer. David Boddie wrote: > > You can use QPainter::setRedirected() to redirect painting operations for > the button to a QImage or QPixmap, send it a paint event, and restore > normal painting behavior afterwards: I 'll try this out, and post the results ! > > QPixmap pixWidget(100, 100); > pixWidget.fill(QColor(0,0,0,0)); > > QPainter::setRedirected(&pushButton, &pixWidget); > QPaintEvent paintEvent(pixWidget.rect()); > qApp->notify(&pixWidget, &paintEvent); > QPainter::restoreRedirected(&pushButton); > >> The pixmap is never rendered correctly (I get all these ugly things one >> get with transparency when it does not work correctly). > > This is usually because you need to fill the pixmap using a color with an > alpha component before you paint the widget on it. I saw that you did > this, but it doesn't explain why you have problems with transparency. Indeed, QPixmap::grabWidget() builds and returns a QPixmap... Hence, there is no way to fill the pixmap before grabWidget() paints on it... Cheers, Nicolas -- [ signature omitted ]
Just for the archive... Indeed, QPixmap::grabWidget(...) does not fill the pixmap before painting on it. That's why transparent widget are not rendered correctly in a pixmap in Qt422 and before. Adding myPixmap.fill(QColor(0,0,0,0)) in the sources of QPixmap::grabWidget(...) makes it. This may be changed in a future release - see the task 142869 in the task tracker. Best- Nicolas Nicolas Castagne wrote: > Thanks for your answer. > > David Boddie wrote: > >> >> You can use QPainter::setRedirected() to redirect painting operations for >> the button to a QImage or QPixmap, send it a paint event, and restore >> normal painting behavior afterwards: > I 'll try this out, and post the results ! >> >> QPixmap pixWidget(100, 100); >> pixWidget.fill(QColor(0,0,0,0)); >> >> QPainter::setRedirected(&pushButton, &pixWidget); >> QPaintEvent paintEvent(pixWidget.rect()); >> qApp->notify(&pixWidget, &paintEvent); >> QPainter::restoreRedirected(&pushButton); >> >>> The pixmap is never rendered correctly (I get all these ugly things one >>> get with transparency when it does not work correctly). >> >> This is usually because you need to fill the pixmap using a color with an >> alpha component before you paint the widget on it. I saw that you did >> this, but it doesn't explain why you have problems with transparency. > > Indeed, QPixmap::grabWidget() builds and returns a QPixmap... Hence, there > is no way to fill the pixmap before grabWidget() paints on it... > > Cheers, > Nicolas -- [ signature omitted ]