iterator.next().contains("service") doesn't work properly
-
HI i'm trying to show in my list widget only files that ends with .service.
i made this:QDirIterator iterator("/lib/systemd/system/"); ui->servicesList->clear(); while(iterator.hasNext()){ if(!iterator.next().contains("service")){ return; } ui->servicesList->addItem(iterator.next()); }
but in my list i can see positions with .target and .socket do you know what's wrong? thanks
-
@jakubiszon26 said in iterator.next().contains("service") doesn't work properly:
iterator.next()
According to the documentation: "Advances the iterator to the next entry, and returns the file path of this new entry. "
return;
this is wrong I would guess
-
QDirIterator iterator("/lib/systemd/system/"); ui->servicesList->clear(); while(iterator.hasNext()){ const auto current = iterator.next(); if(current.contains("service")) ui->servicesList->addItem(current ); }
@VRonin thanks a lot.