setting and reading multiple genres

Andrew Lake jamboarder at gmail.com
Tue Nov 2 05:24:38 CET 2010


Hello and thanks much for sharing your work on taglib.

I am working on trying to set multiple id3v2 genres and I need a
little help to get me on the right track.  Below is the code snippet
I'm using (genreList is QStringList containing the genres i'd like to
set):

                    if (!genreList.isEmpty()) {
                        TagLib::String
genre(genreList.at(0).toUtf8().data(), TagLib::String::UTF8);
                        for (int i = 1; i < genreList.count(); i++) {
                            genre.append('\0');
                            genre.append(genreList.at(i).toUtf8().data());
                        }
                        file.tag()->setGenre(genre);
                    }
                    file.save();

The above snippet only saves the first genre in genreList.  Could
anyone point me to the correct way to save multiple genres?
Additionally, will this kind of method work for multiple artists?

Thanks for any help anyone can provide.

peace and much respect,
Andrew Lake


More information about the taglib-devel mailing list