Results 1 to 12 of 12

Thread: QGraphicsScene/QGraphicsView window limitations

  1. #1
    Join Date
    Feb 2007
    Posts
    32
    Thanks
    3

    Default QGraphicsScene/QGraphicsView window limitations

    i am an undergraduate student working with Qt. i've used QPolygonF to create polygons that have been attached to a scene as pathitems. using the following code for attaching points:

    polygonC << QPointF(x,y);

    x values range from 0 to 5000 and y values range from 0 to 150.

    after successfully plotting the data, i have noticed that the majority of the data has not been plotted. examine the screenshot below.


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

    Default Re: QGraphicsScene / QGraphicsView window limitations

    What is the size of your QGraphicsScene?

  3. #3
    Join Date
    Feb 2007
    Posts
    32
    Thanks
    3

    Default Re: QGraphicsScene/QGraphicsView window limitations

    i initialized QGraphicsScene without parameters, for example, QGraphicsScene myScene.

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

    Default Re: QGraphicsScene/QGraphicsView window limitations

    What does polygonC.boundingRect() return?

  5. #5
    Join Date
    Feb 2007
    Posts
    32
    Thanks
    3

    Default Re: QGraphicsScene/QGraphicsView window limitations

    whats the best way to display the information returned from polygonC.boundingRect()? through QMessageBox?

    EDIT: i was unable to figure out how to display the information returned from .boundingRect(), however i set:

    QGraphicsScene *scene = new QGraphicsScene(0,0,50000,0);

    i noticed that the all four curves are cut off. is there a limitation on QPolygonF?
    Last edited by mistertoony; 15th February 2007 at 18:47.

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

    Default Re: QGraphicsScene/QGraphicsView window limitations

    Quote Originally Posted by mistertoony View Post
    whats the best way to display the information returned from polygonC.boundingRect()? through QMessageBox?
    qDebug() should be the quickest one.

  7. #7
    Join Date
    Feb 2007
    Posts
    32
    Thanks
    3

    Default Re: QGraphicsScene/QGraphicsView window limitations

    jacek, polygons are cut off. im wondering if there is a maximum number of points a polygon may have.
    Last edited by mistertoony; 15th February 2007 at 18:56.

  8. #8
    Join Date
    Jan 2006
    Location
    Norway
    Posts
    124
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows
    Thanked 38 Times in 30 Posts

    Default Re: QGraphicsScene/QGraphicsView window limitations

    You might have run into a bug that was recently fixed; try applying this patch and see if it helps...

    Qt Code:
    1. --- qgraphicsview.cpp 2007/02/05 13:30:58.000000000
    2. +++ qgraphicsview.cpp 2007/02/12 16:26:20.000000000
    3.  
    4. @@ -338,6 +338,14 @@
    5. int height = maxSize.height();
    6. QRectF viewRect = matrix.mapRect(q->sceneRect());
    7.  
    8. + // Adjust the maximum width and height of the viewport based on the width
    9. + // of visible scrollbars.
    10. + int scrollBarExtent = q->style()->pixelMetric(QStyle::PM_ScrollBarExtent, 0, q);
    11. + if (viewRect.width() >= maxSize.width())
    12. + height -= scrollBarExtent;
    13. + if (viewRect.height() >= maxSize.height())
    14. + width -= scrollBarExtent;
    15. +
    16. // Setting the ranges of these scroll bars can/will cause the values to
    17. // change, and scrollContentsBy() will be called correspondingly. This
    18. // will reset the last center point.
    To copy to clipboard, switch view to plain text mode 
    Bitto / Andreas Aardal Hanssen - andreas dot aardal dot hanssen at nokia
    Nokia Software Manager, Qt Development

  9. #9
    Join Date
    May 2006
    Location
    Bangalore,India
    Posts
    235
    Qt products
    Qt3 Qt4
    Platforms
    Windows
    Thanks
    7
    Thanked 25 Times in 24 Posts

    Default Re: QGraphicsScene/QGraphicsView window limitations

    First you initialize QGraphicsScene without parameters, for example,
    QGraphicsScene myScene.

    later you calculate rect area(width & height) after drawing all items, then set following

    scene->setSceneRect(0, 0, width,height);

    (width = width of longest QGrapicsItem)


    This will set scroll bar automatically. No need to set yourself.

  10. #10
    Join Date
    Feb 2007
    Posts
    32
    Thanks
    3

    Default Re: QGraphicsScene/QGraphicsView window limitations

    Quote Originally Posted by rajesh View Post
    First you initialize QGraphicsScene without parameters, for example,
    QGraphicsScene myScene.

    later you calculate rect area(width & height) after drawing all items, then set following

    scene->setSceneRect(0, 0, width,height);

    (width = width of longest QGrapicsItem)


    This will set scroll bar automatically. No need to set yourself.
    how do i calculate the rect area? i believe the problem is that polygons are unfinished, i manually extended the width of the scene and the polygons appear cut off.


  11. #11
    Join Date
    Feb 2007
    Posts
    32
    Thanks
    3

    Default Re: QGraphicsScene/QGraphicsView window limitations

    Quote Originally Posted by Bitto View Post
    You might have run into a bug that was recently fixed; try applying this patch and see if it helps...

    Qt Code:
    1. --- qgraphicsview.cpp 2007/02/05 13:30:58.000000000
    2. +++ qgraphicsview.cpp 2007/02/12 16:26:20.000000000
    3.  
    4. @@ -338,6 +338,14 @@
    5. int height = maxSize.height();
    6. QRectF viewRect = matrix.mapRect(q->sceneRect());
    7.  
    8. + // Adjust the maximum width and height of the viewport based on the width
    9. + // of visible scrollbars.
    10. + int scrollBarExtent = q->style()->pixelMetric(QStyle::PM_ScrollBarExtent, 0, q);
    11. + if (viewRect.width() >= maxSize.width())
    12. + height -= scrollBarExtent;
    13. + if (viewRect.height() >= maxSize.height())
    14. + width -= scrollBarExtent;
    15. +
    16. // Setting the ranges of these scroll bars can/will cause the values to
    17. // change, and scrollContentsBy() will be called correspondingly. This
    18. // will reset the last center point.
    To copy to clipboard, switch view to plain text mode 
    i can't find this cpp file on my system.

  12. #12
    Join Date
    Jan 2006
    Location
    Norway
    Posts
    124
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows
    Thanked 38 Times in 30 Posts

    Default Re: QGraphicsScene/QGraphicsView window limitations

    The patch is against Qt's source code; you can download the sources, apply the patch, and compile/install the library, or wait for an official upgrade (this patch is part of 4.3).
    Bitto / Andreas Aardal Hanssen - andreas dot aardal dot hanssen at nokia
    Nokia Software Manager, Qt Development

Similar Threads

  1. move parent window to the front.
    By hvengel in forum Qt Programming
    Replies: 4
    Last Post: 2nd February 2007, 09:41
  2. right way to open a new window
    By wind in forum Newbie
    Replies: 1
    Last Post: 1st November 2006, 12:17
  3. Replies: 3
    Last Post: 23rd July 2006, 19:02
  4. Move window in Clone Mode
    By ultrabrite in forum Qt Programming
    Replies: 1
    Last Post: 14th June 2006, 19:22
  5. cannot make a main window modal
    By Dark_Tower in forum Qt Programming
    Replies: 12
    Last Post: 23rd March 2006, 11:21

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
  •  
Qt is a trademark of The Qt Company.