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
QtWS25 Last Chance

QSqlQueryModel with escaped characters in database

Scheduled Pinned Locked Moved Solved General and Desktop
setqueryqsqlquerymodel
4 Posts 2 Posters 417 Views
  • 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 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
    • Christian EhrlicherC Offline
      Christian EhrlicherC Offline
      Christian Ehrlicher
      Lifetime Qt Champion
      wrote on 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
      5
      • Christian EhrlicherC Christian Ehrlicher

        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 last edited by
        #3

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

        1 Reply Last reply
        0
        • Christian EhrlicherC Christian Ehrlicher

          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 last edited by
          #4

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

          1 Reply Last reply
          0

          • Login

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