Results 1 to 4 of 4

Thread: Why QPainter::rotate doesn't affect QPainter::boundingRect?

  1. #1
    Join Date
    Jan 2006
    Location
    Catalonia
    Posts
    266
    Thanks
    44
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Why QPainter::rotate doesn't affect QPainter::boundingRect?

    Hi I want to know why QPainter::boundingRect returns the same QRect with or without rotation. I think that if some rotation is fixed, the bounding rect has to change too... What do you think?

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Why QPainter::rotate doesn't affect QPainter::boundingRect?

    Because when you rotate or translate the painter you change only the coordinate system it uses.

    Suppose you have a class that receives a QPainter instance and draws some text on it (like QTextDocumentLayout or Q3CanvasItem). When you rotate the painter, everything that class paints will be rotated, but it doesn't have to know that you have rotated the painter --- it just draws using the current coordinate system.

    Now if QPainter::boundingRect() would return a different rectangle depending on how much you have rotated the painter, it would brake everything --- suddenly the mentioned class would start drawing things differently if the painter was rotated and you wouldn't like that.

  3. The following user says thank you to jacek for this useful post:

    SkripT (30th April 2006)

  4. #3
    Join Date
    Jan 2006
    Location
    Catalonia
    Posts
    266
    Thanks
    44
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Why QPainter::rotate doesn't affect QPainter::boundingRect?

    Thanks jacek, thinking a little bit more in the problem I reached the same concclusion So, how could I know the bounding rectangle of a rotated text? Exists an easy way to do it? or I have to applicate maths?
    Last edited by SkripT; 30th April 2006 at 20:03.

  5. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Why QPainter::rotate doesn't affect QPainter::boundingRect?

    Try QMatrix.

  6. The following user says thank you to jacek for this useful post:

    SkripT (30th April 2006)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.