1
votes

I am trying to implement a custom maps, which is consists on multiple tile images.

I could successfully load tiles based on viewport Rect.

void updateRasterTiles(const QRectF &viewport)
{
    .....
    Q_FOREACH(QString fileName, fileNames)
    {
        XXX::IRasterGISItem* rasterGISItem = provider->provide(fileName);
        QGraphicsItem* graphicsItem = dynamic_cast<QGraphicsItem*>(rasterGISItem);
        graphicsItem->setPos(d->tilesResolutionTopLeftDirectoryHash.key(fileName)->x(),
                             d->tilesResolutionTopLeftDirectoryHash.key(fileName)->y());
        rasterGISLayerItem->addRasterGISItem(rasterGISItem);
    }
    .....
}

So, whenever i give topleft and bottomRight coordinates, it successfully loads the images on the QGraphicsItem.

Issue:-

i am looking for something like signal or event,

Where, if viewport coordinate changes via mouse drag / wheel (zoom in/out), i can all this updateRasterTiles(const QRectF & viewport)

1

1 Answers

2
votes

Qt simply does not have this functionality, despite it being such a simple and very frequently needed one. The closest approximation is to attach to the valueChanged signals of the view's scrollbars. But it will not detect all viewport changes, in particular when you zoom out so that the scroll bars got deactivated. You will need to handle this case manually. The worst part of it is that it is easy to overlook some other way the viewport may change.