Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

Painter not painting over 32,765 px in width of QGraphicsItem/QGraphicsObject



  • I have a QGraphicsItem/QGraphicsObject that's going to expand in width on scroll, and I have filled the background with a red. The problem came when my width got over 32,765 px, the painter stopped painting those area, so I ended up with no red background for the end of the item.

    mygraphicsitem.cpp

    QRectF MyItem::boundingRect() const
    {    
        return QRectF(0, 0, 33000, 40);
    }
    
    void MyItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
    {    
        QBrush redBrush(Qt::red);
        QRectF rec = boundingRect();
    
        painter->fillRect(rec, redBrush);
    

  • Lifetime Qt Champion

    Hi
    https://doc.qt.io/qt-5/qpainter.html#details
    "if you are using coordinates with Qt's raster-based paint engine, it is important to note that, while coordinates greater than +/- 2^15 can be used, any painting performed with coordinates outside this range is not guaranteed to be shown; the drawing may be clipped. This is due to the use of short int in the implementation."

    I think this is what you are seeing.



  • @mrjj Thanks, so I hit the limit. I'll try not to go over that.