Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. QSqlQueryModel with escaped characters in database
Forum Updated to NodeBB v4.3 + New Features

QSqlQueryModel with escaped characters in database

Scheduled Pinned Locked Moved Solved General and Desktop
setqueryqsqlquerymodel
4 Posts 2 Posters 569 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • R Offline
    R Offline
    rjmx
    wrote on 21 Nov 2021, 08:44 last edited by
    #1

    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

    1 Reply Last reply
    0
    • C Offline
      C Offline
      Christian Ehrlicher
      Lifetime Qt Champion
      wrote on 21 Nov 2021, 09:05 last edited by
      #2

      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.

      Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
      Visit the Qt Academy at https://academy.qt.io/catalog

      R 2 Replies Last reply 21 Nov 2021, 20:06
      5
      • C Christian Ehrlicher
        21 Nov 2021, 09:05

        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.

        R Offline
        R Offline
        rjmx
        wrote on 21 Nov 2021, 20:06 last edited by
        #3

        @Christian-Ehrlicher Thanks. I’ll try that..

        1 Reply Last reply
        0
        • C Christian Ehrlicher
          21 Nov 2021, 09:05

          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.

          R Offline
          R Offline
          rjmx
          wrote on 23 Nov 2021, 00:34 last edited by
          #4

          @Christian-Ehrlicher Yep. QIdentityProxyModel works fine. Thanks.

          1 Reply Last reply
          0

          1/4

          21 Nov 2021, 08:44

          • Login

          • Login or register to search.
          1 out of 4
          • First post
            1/4
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • Users
          • Groups
          • Search
          • Get Qt Extensions
          • Unsolved