Why is 4th argument in match() 5 ?
Why is 4th argument in match() 5 ?
When you know how to do it then you may do it wrong.
When you don't know how to do it then it is not that you may do it wrong but you may not do it right.
In fact I only expect to get 1 index in myFinded (the values in the table are Uniques). But the application didn't work propertly so I have increased Hits (number of hits until macht stop searching) from 1 to 5 (number of items in my table) to debug.
If myValue is other than 0, all work good, but when myValue=0 I get 2 indexes in myFinded
I found the problem (not the solution)
QAbstractItemModel::match compares each value from the model with the searched value and return the indexes that match.
it uses the operator== method of QVariant, but it doesn't work fine
my table is table.PNG
I getQt Code:
miConsulta->setQuery("Select Valor, Descripcion From myTable");To copy to clipboard, switch view to plain text mode
var1
value: 0
type: QVariant(int)
isnull: false
var2
value:0
type: QVariant(int)
isnull: true
but var1==var2 return TRUE !!!!!!!!!
how can a null variant be equal to anything?????????
can somebody explain?
thank's
That's the way it is
Originally Posted by Qt Documentation
When you know how to do it then you may do it wrong.
When you don't know how to do it then it is not that you may do it wrong but you may not do it right.
Koyi (24th February 2017)
By the way, do you realize that this is incorrect syntax for OR-ing flags?
Qt Code:
Qt::MatchFlags(Qt::MatchExactly || Qt::MatchWrap)To copy to clipboard, switch view to plain text mode
It should be this:
Qt Code:
Qt::MatchFlags(Qt::MatchExactly | Qt::MatchWrap)To copy to clipboard, switch view to plain text mode
A simple typo like this could lead to all sorts of unexplained behavior, because the result of the logical OR (||) will probably not be the same as the result of the bitwise OR (|).
<=== The Great Pumpkin says ===>
Please use CODE tags when posting source code so it is more readable. Click "Go Advanced" and then the "#" icon to insert the tags. Paste your code between them.
Koyi (24th February 2017)
Bookmarks