@JKSH Thanks.
By using of RegExp, the problem is solved.
For other users who read this question:
My main string is a string of hex (without any space or \x or 0x). I replcae ? in substring by [0-9a-f] and use Qt::CaseInsensitive option:
regex.replace("?","[0-9a-f]");
index = mainString.indexOf(QRegExp(regex,Qt::CaseInsensitive));