Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

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

    General and Desktop
    qpainter qgraphicsitem qgraphicsobject
    2
    3
    237
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • L
      lansing last edited by lansing

      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);
      
      1 Reply Last reply Reply Quote 0
      • mrjj
        mrjj Lifetime Qt Champion last edited by

        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.

        L 1 Reply Last reply Reply Quote 1
        • L
          lansing @mrjj last edited by

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

          1 Reply Last reply Reply Quote 0
          • First post
            Last post