View Single Post
Posts: 52 | Thanked: 8 times | Joined on Apr 2010
#1
I am trying to see if a certain string starts with a string that is entered into a text box:

Code:
QStringList temp = allServices;
    QString current;

    for(int i = 0; i < temp.size(); ++i)
    {
        current = temp.at(i);

        if(!current.startsWith(text, Qt::CaseInsensitive))
        {
            QMessageBox msg;
            msg.setText("Removing " + temp.at(i));
            msg.exec();

            temp.removeAt(i);
        }
    }
'text' is the input string, which comes directly from the 'text_changed' slot for the input box and the for loop iterates through the QStringList and checks for matches (technically NON matches). However, a few examples of matches and non matches when the letter 'C' is compared with each item are as follows:

MATCH: ('org.freedesktop.Notifications' is compared with 'C')
NON-MATCH: ('org.freedesktop.DBus' is compared with 'C')

I cannot see how it thinks the first one starts with a 'C' and the second one doesn't.

I have retrieved a list of all of the DBUS services in string format and I am filtering those strings through a text box by a user-entered string. Is there some sort of format problem here?

(PS: I put the message box in to see which ones it was actually removing from the list)