factorize a bit ? E.g.
```
QString query = "select * from " + d->queryTableName;
if (not empty)
  {
  query += ...
```