Qt- change QStringList element

1.4k views Asked by At

I have groupProfpic as QStringList. I'v added the same photo to all of element

for (int k=0 ; k<4 ; ++k)
    groupProfpic.append(":/images/person.png");

If each person has profile picture ,default profile picture(":/images/person.png") will replace to his/her profile picture.

   for (int i=0 ; i<nicknamesList.size() ; ++i)
        {
            query1.prepare("SELECT profpic FROM muc_members WHERE nickname=? LIMIT 4");
            query1.addBindValue(nicknamesList[i]);
            query1.exec();
            if(query1.next())
            {
                groupProfpic[i] = query1.value(0).toString();
            }

but it's not working. How to fix it?

1

There are 1 answers

0
Yaroslav On

Try to check return value of QSqlQuery::exec():

if (query1.exec()) {
    //do your work
    //and see what you have
    qDebug() << "Image path:" << query1.value(0).toString(); 
}
else {
    //you have an error
}