QSqlQueryModel with escaped characters in database
-
Some background here. I’ve been a C programmer for around 30 years, but I’m new to C++. I have an application that I wrote in C ten years ago for GTK+, and, since that’s gone down the drain, I decided Qt was the way to go. Still using Qt5, because Debian testing hasn’t caught up with Qt6 yet. Doing well so far, but now I have a problem.
I have text data stored in an sqlite database, with non-alphanumeric characters stored as “%xx”, where “xx” is the hex equivalent of the character.
I’m using QSqlQueryModel, using setQuery(), which, as far as I can see, is the only real way to get data into the model. Trouble is, it reads the whole table in in one shot, meaning that there’s no obvious way to intercept the data and unescape it. I’ve written code to do the unescaping, but I don’t see how to use it.
So, have I missed something? Any suggestions on going about this?
Thanks,
…..Ron
-
Use either a completely custom model and do the fetching by yourself or add a QIdentityProxyModel and change the content in data() the way you want.
-
@Christian-Ehrlicher Thanks. I’ll try that..
-
@Christian-Ehrlicher Yep. QIdentityProxyModel works fine. Thanks.