(Regression in Qt-3.1-beta2) Bug in QPainter::setClipRegion

David Faure david at mandrakesoft.com
Fri Oct 11 18:23:24 BST 2002


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

The standalone testcase below shows a new bug in Qt-3.1-beta2
(compared to a 3.0.6-snapshot, I don't know about Qt-3.1-beta1).

This program pops up a widget that should paint a red rectangle of size 60x60,
at (100,100) (due to the painter translation).

In Qt-3.1-beta2 it doesn't show up initially, one has to resize the window to see
it appear (even simply moving another window on top, to force a repaint, doesn't
work).

Works without the translate() call, works without the setClipRegion()... This is why
I'm suspecting the bug is in the setClipRegion call somehow.


#include <qapp.h>
#include <qpainter.h>
#include <qwidget.h>

class MyWidget : public QWidget
{
public:
  MyWidget() : QWidget() {}
  virtual void paintEvent( QPaintEvent * ) {
      QPainter painter( this );
      QRect r( 0, 0, 60, 60 );
      QRegion reg( r );
      reg -= QRect( 10, 10, 40, 40 ); // not necessary, but explains why this setClipRegion/fillRect approach is used
      painter.translate( 100, 100 );
      painter.setClipRegion( reg, QPainter::CoordPainter );
      painter.fillRect( reg.boundingRect(), QBrush( Qt::red ) );
  }
};

int main ( int argc, char **argv)
{
    QApplication a(argc, argv);
    QWidget * w = new MyWidget();
    a.setMainWidget(w);
    w->show();
    return a.exec();
}

- -- 
David FAURE, david at mandrakesoft.com, faure at kde.org
http://people.mandrakesoft.com/~david/
Contributing to: http://www.konqueror.org/, http://www.koffice.org/
Get the latest KOffice - http://download.kde.org/stable/koffice-1.2/
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.7 (GNU/Linux)

iD8DBQE9pwkO72KcVAmwbhARAhW4AKCnaxPyrcV2j2ek4WHxBf8PqGoDyQCbBptZ
KhN9LB1Jx0JQVrNB7zwdoIE=
=Aa+L
-----END PGP SIGNATURE-----





More information about the kde-core-devel mailing list