Important: Please read the Qt Code of Conduct -

How to judge class object is null ?

  • TileItem::TileItem(QGraphicsItem *parent) : QGraphicsPixmapItem(parent)
    TileItem::TileItem(QString &surl)
    void TileItem::setPixmapFormUrl(QString surl)
        QNetworkAccessManager *NAM = new QNetworkAccessManager;
        QNetworkRequest request;
        connect(NAM, &QNetworkAccessManager::finished, [=](QNetworkReply *reply){
            QPixmap pixmap;
                setPixmap(pixmap);//if it is deleted in parent, here will crash.

  • Not sure I understand the question...

  • Lifetime Qt Champion

    @sonichy hi,

    I would say that your design has issues. Creating a QNAM for each tile when you want to a remote image is rather wasteful.

    You should rather have a dedicated class that manages the retrieval of the images and setting them on the appropriate tile. That way you can also cancel the retrieval on tile deletion.

Log in to reply