Error in receiving the unsigned char * (image)



  • i hve written the code like this
    @
    code
    @

    QBuffer imagebuffer;
    qint64 bytes = imagebuffer->write((const char
    ) buf,sizeof(buf)); // buf is received unsigned char*
    imagebuffer->seek(imagebuffer->pos() - bytes);
    cout<<"bytes:"<<bytes<<endl;
    QImage receivedImage;
    receivedImage.loadFromData(imagebuffer->buffer());
    if(!receivedImage.isNull()){
    qDebug() << "Image file was received ";
    }

       ui->img->setPixmap(QPixmap::fromImage(receivedImage);
    

    }

    when i execute this am getting error as
    segmentation fault

    can any body suggest me what and where is the error
    thank u


  • Lifetime Qt Champion

    Hi,

    Please enclose your code in coding tags, that will make it readable.

    As for your problem:
    You don't initialize imagebuffer



  • Please ask your question on the "General and Desktop forum":http://qt-project.org/forums/viewforum/10/.
    This forum is for contributions to Qt.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.