Results 1 to 4 of 4

Thread: Error in QRectF::intersects

  1. #1
    Join Date
    Dec 2006
    Posts
    426
    Thanks
    8
    Thanked 18 Times in 17 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Error in QRectF::intersects

    When the input QRectF has a 0 width, that is, it is a line, the function simply returns "false"

    If so, I hope QRectF can provide a method
    bool QRectF::intersects( const QLineF& )

  2. #2
    Join Date
    Feb 2009
    Location
    Noida, India
    Posts
    517
    Thanks
    21
    Thanked 66 Times in 62 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Error in QRectF::intersects

    well, why dont u derive from QRectF and write the function urself. I dont think QT guys are gonna add anything like that

  3. #3
    Join Date
    Dec 2006
    Posts
    426
    Thanks
    8
    Thanked 18 Times in 17 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Error in QRectF::intersects

    Quote Originally Posted by talk2amulya View Post
    well, why dont u derive from QRectF and write the function urself. I dont think QT guys are gonna add anything like that
    Having QRectF, QLineF, QPointF, and
    QRectF::intersects( const QRectF& )
    QRectF::contains( const QPointF& )
    QLine::intersect( const QLineF& ) // <== why not use "intersects" to be consistent?

    and it is reasonable to expect QRectF::intersects( const QLineF& ). It is definitely needed for rendering purpose.

    I need to draw a polyline with over 20,000 points, it is very slow to draw them all when there is an exposure event, and I found QStyleOptionGraphicsItem::exposedRect

    So I do

    Qt Code:
    1. for ( int idx = 0; idx < totalPoints; idx++ ) {
    2. QPointF p1 = ...
    3. QPointF p2 = ...
    4. If ( exposedRect.intersects( QLineF( p1, p2 ) ) { // perhaps I need to do QLineF::cutThrough( const QRectF& )?
    5. painter->drawLine( p1, p2 );
    6. }
    7. }
    To copy to clipboard, switch view to plain text mode 

    That is, only line segment that intersects with the exposed rectangle, then I do the draw. This improves the performance tremendously. Yes, I write my own "intersects" for now. But it should be provided by Qt as it is definitely needed for fast rendering.

    This bring up my other question, what does QPainter do behind the scene? Performance is very bad when trying to draw a polyline with over 10,000 points, although the exposed area may only have 20 points...

    But after adding "intersetcs", it becomes much faster even though checking has to be done for all line segments...

  4. #4
    Join Date
    Feb 2009
    Location
    Noida, India
    Posts
    517
    Thanks
    21
    Thanked 66 Times in 62 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Error in QRectF::intersects

    u do make a valid point, maybe u should take over this issue to trolltech or to Nokia now also the thing u said about consistency makes sense too

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.