Hello All -

Problem in the new Qt 4.6 RC 1 released today.

The attached small example illustrates the problem:

With a pen enabled and the graphics item's opacity() <1.0, the pen appears to be rendered *after* the brush (see attached screenshot 'prob1.png'), and appears to be rendered as a solid rectangle (e.g. the rectangle drawn with the brush is rendered below a rectangle drawn with the pen.) It should be noted that at 1.0 opacity, drawRect() renders correctly.

However, if the drawRect() call is ran without any pen set, then the rectangle renders fine. Additionally, with a regular viewport (no setViewport(new QGLWidget()) call), the drawRect() method does not show this problem. (See Attached screenshot 'prob2.png' - no pen enabled when drawRect() called - thats the ONLY difference between the two screenshots.)

I'm running Fedora 8 on Linux2.6.23.9-85.fc8 #1 SMP.

Can anyone else replicate this problem or have any ideas how to fix it?

Thanks!
-josiah

--

-=-=-=-=-=-=-=-=-=-=-=-=-
Josiah Bryan
Productive Concepts, Inc.
[email protected]
(765) 964-6009, ext. 224
#include <QtGui/QApplication>
#include <QGraphicsView>
#include <QGraphicsItem>
#include <QtOpenGL/QGLWidget>
#include <QDebug>

class BoxItem : public QGraphicsItem
{
public:

        QRectF rect;
        QBrush brush;
        QPen pen;

        BoxItem(QGraphicsScene * scene, QGraphicsItem * parent) 
                : QGraphicsItem(parent, scene)
                , rect(0,0,500,500)
                , brush(QColor(255,0,0,255))
                , pen(QColor(0,0,0,255), 3.0)
        {
                
        }

        QRectF boundingRect() const
        {
                return rect;
        }

        void paint(QPainter * painter, const QStyleOptionGraphicsItem * 
/*option*/, QWidget * /*widget*/)
        {
                painter->setPen(pen);
                painter->setPen(Qt::NoPen);
                painter->setBrush(brush);
                painter->drawRect(rect);
        }
};

int main(int argc, char **argv)
{
        QApplication app(argc, argv);

        QGraphicsView *graphicsView = new QGraphicsView();
        graphicsView->setViewport(new QGLWidget(QGLFormat(QGL::SampleBuffers)));
        graphicsView->setRenderHint( QPainter::Antialiasing, true );

        QGraphicsScene * scene = new QGraphicsScene();

        graphicsView->setScene(scene);
        scene->setSceneRect(0,0,800,600);
        graphicsView->resize(800,600);
        graphicsView->setWindowTitle("Test");

        BoxItem *root = new BoxItem(scene,0);
        root->setPos(10,10);
        root->setOpacity(.5);
        
        graphicsView->show();

        return app.exec();
}

TEMPLATE = app
TARGET = 
DEPENDPATH += .
INCLUDEPATH += .
QT += opengl

# Input
SOURCES += main.cpp

<<inline: prob1.png>>

<<inline: prob2.png>>

_______________________________________________
Qt4-preview-feedback mailing list
[email protected]
http://lists.trolltech.com/mailman/listinfo/qt4-preview-feedback

Reply via email to