Fellow Qt developers, I seek your wisdom!
I have this kind of code
void QGSLayer::updateFeatures(int zoom)
{
if(lyrType == DynamicLayer)
{
QGSCoordinateTransform ct;
ct.setZoom(zoom);
for(int i=0;i<this->childItems().count();i++)
{
QPointF ptG
= ct.
metersToLatLon(ct.
pixelsToMeters(item
->pos
().
toPoint()));
QPoint pt
= coordTransform
->metersToPixels
(coordTransform
->latLonToMeters
(ptG
));
item->setPos(pt);
}
}
}
void QGSLayer::updateFeatures(int zoom)
{
if(lyrType == DynamicLayer)
{
QGSCoordinateTransform ct;
ct.setZoom(zoom);
for(int i=0;i<this->childItems().count();i++)
{
QGraphicsItem *item = childItems().at(i);
QPointF ptG = ct.metersToLatLon(ct.pixelsToMeters(item->pos().toPoint()));
QPoint pt = coordTransform->metersToPixels(coordTransform->latLonToMeters(ptG));
item->setPos(pt);
}
}
}
To copy to clipboard, switch view to plain text mode
QGSLayer is subclassed from QGraphicsItemGroup. It contains different items that were successfully added to the scene and displayed.
The problem is... childItems().count() returns correct amount of items but when I try to read their positions I always get 0, 0. But it isn't true (as you can see in the image attached). Maybe someone can explain this kind of behavior?
Thanx in advance!
Bookmarks