QSet::isEmpty() return's false while no data in it
-
I've tried to compare 2 same list with
QSet<QString> add_chart = list2.toSet().subtract(list1.toSet());while print add_chart in qdebug , it shows in console like : QSet("")
However,
add_chart.isEmpty() still returns false,
is there some reason in it and how to solve this?create a iterator to check if Qstring.isempty()?
-
@Puppy-Bear
thisQSet("")
doesn't look empty, it seems like there's an empty QString in it -> isEmpty() will return false -
Please show the real code, with correct test data so we can take a look what's wrong. This is fine for me:
QList<QString> list1 = {"one", "two"}; QList<QString> list2 = {"two", "one"}; QSet<QString> add_chart = list2.toSet().subtract(list1.toSet()); qDebug() << add_chart; qDebug() << add_chart.isEmpty(); return 0;
-->
QSet() true
-
@Puppy-Bear
thisQSet("")
doesn't look empty, it seems like there's an empty QString in it -> isEmpty() will return false -
@Christian-Ehrlicher Sry it's a list of data from database, so it might cannot be showned on this screen yet. Guess it's something wrong with reading the db file