[SOLVED] IndexOf() in QVariantList
I have a QVariantList of QStrings and doubles similar to this
list << "hello" << 80 << "bye" << 120; @
When I try
I get -1 (should be 0).
I have tried
but I get the same value. How could I find the index of a QVariant(QString) in a QVariantList?
the method's you've posted work fine for me.
list << "hello" << 80 << "bye" << 120;
qDebug() << list.indexOf("bye"); //returns 2
What Qt version are you using?
oops, you're right, this code works. I was trying to simplify my actual code, but I hadn't tried it. My real code is a bit more complicated.
I was posting it when I realized I was passing a wrong string argument to indexOf. I was asking it to find "backroundThreshold" and should've been "backgroundThreshold:NUMBER". Hence the -1.
Thanks for you help!