Important: Please read the Qt Code of Conduct -

[SOLVED] QTableView + QStyledItemDelegate + BLOB Image - Having problems when I update an existing image to a new image.

  • Hello
    I am currently using a TableView that has an QStyledItemDelegate to display the image that is stored as BLOB in a MySQL database. I am having a problem when I need to change an image in one cell. Please help. This is what i am currently doing.

    Now in some locations (cells - Column 3) I use a default image. I use a QTAbleview::clicked signal and in the corresponding cell index, i call a QFileDialog to get a filename. From the filename I get a QByteArray which i then use a QSqlQuery to update the database (I get no errors). Once i do that i call a function called refresh model which in essence reloads the entire model to the view. But somehow the image stays default (The last image does not update to the new one).
    Please help.

  • Lifetime Qt Champion


    Did you check that the data in your database did in fact get changed ?
    Are you sure the database has been reloaded ?

  • Thanks SGaist. That was infact the problem. I read the ByteArray before and after writing and it was the same. Then I noticed I made a mistake while calling the addbindvalue. Corrected that and now it works like a charm

Log in to reply