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.
http://www2.bc.edu/~nguyenah/sct_plot2.JPG
Re: QGraphicsScene / QGraphicsView window limitations
What is the size of your QGraphicsScene?
Re: QGraphicsScene/QGraphicsView window limitations
i initialized QGraphicsScene without parameters, for example, QGraphicsScene myScene.
Re: QGraphicsScene/QGraphicsView window limitations
What does polygonC.boundingRect() return?
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?
Re: QGraphicsScene/QGraphicsView window limitations
Quote:
Originally Posted by
mistertoony
whats the best way to display the information returned from polygonC.boundingRect()? through QMessageBox?
qDebug() should be the quickest one.
Re: QGraphicsScene/QGraphicsView window limitations
jacek, polygons are cut off. im wondering if there is a maximum number of points a polygon may have.
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...
Code:
--- qgraphicsview.cpp 2007/02/05 13:30:58.000000000
+++ qgraphicsview.cpp 2007/02/12 16:26:20.000000000
@@ -338,6 +338,14 @@
int height = maxSize.height();
QRectF viewRect
= matrix.
mapRect(q
->sceneRect
());
+ // Adjust the maximum width and height of the viewport based on the width
+ // of visible scrollbars.
+ int scrollBarExtent
= q
->style
()->pixelMetric
(QStyle::PM_ScrollBarExtent,
0, q
);
+ if (viewRect.width() >= maxSize.width())
+ height -= scrollBarExtent;
+ if (viewRect.height() >= maxSize.height())
+ width -= scrollBarExtent;
+
// Setting the ranges of these scroll bars can/will cause the values to
// change, and scrollContentsBy() will be called correspondingly. This
// will reset the last center point.
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.
Re: QGraphicsScene/QGraphicsView window limitations
Quote:
Originally Posted by
rajesh
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.
http://www2.bc.edu/~nguyenah/scf_plot3.JPG
Re: QGraphicsScene/QGraphicsView window limitations
Quote:
Originally Posted by
Bitto
You might have run into a bug that was recently fixed; try applying this patch and see if it helps...
Code:
--- qgraphicsview.cpp 2007/02/05 13:30:58.000000000
+++ qgraphicsview.cpp 2007/02/12 16:26:20.000000000
@@ -338,6 +338,14 @@
int height = maxSize.height();
QRectF viewRect
= matrix.
mapRect(q
->sceneRect
());
+ // Adjust the maximum width and height of the viewport based on the width
+ // of visible scrollbars.
+ int scrollBarExtent
= q
->style
()->pixelMetric
(QStyle::PM_ScrollBarExtent,
0, q
);
+ if (viewRect.width() >= maxSize.width())
+ height -= scrollBarExtent;
+ if (viewRect.height() >= maxSize.height())
+ width -= scrollBarExtent;
+
// Setting the ranges of these scroll bars can/will cause the values to
// change, and scrollContentsBy() will be called correspondingly. This
// will reset the last center point.
i can't find this cpp file on my system.
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).