Suggestion: factor out BitcoinAddress(text.toStdString()) and store it somewhere. It is repeated many times in the below code.