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. Qt MSSQL check box
QtWS25 Last Chance

Qt MSSQL check box

Scheduled Pinned Locked Moved General and Desktop
6 Posts 2 Posters 2.6k 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.
  • C Offline
    C Offline
    confused
    wrote on last edited by
    #1

    I am using MSSQL and have a field for if the record is currently active or not that is bit data type. How can I make this show up as a check box instead of it wanting the user to type in a number?

    Also, I am using QSqlTableModel and QTableView if that matters.

    1 Reply Last reply
    0
    • A Offline
      A Offline
      andre
      wrote on last edited by
      #2

      Use a proxy model. There are examples on the wiki on how to build proxy models that do similar things.

      1 Reply Last reply
      0
      • C Offline
        C Offline
        confused
        wrote on last edited by
        #3

        Do you know anywhere that has an example of it and explains it? Becuase everything I've found explains what the class can do and has some generic code but I don't know where I'd put it in my code or anything like that.

        Thanks for your help

        1 Reply Last reply
        0
        • A Offline
          A Offline
          andre
          wrote on last edited by
          #4

          Well, the code for my own "checkable proxy model":/wiki/QSortFilterProxyModel_subclass_to_add_a_checkbox contains a complete example on how to use it. Did you take a look at that? It will show you where to put what piece of code. Using the "CheckableSortFilterProxyModel":/wiki/QSortFilterProxyModel_subclass_for_readonly_columns_columns_with_checkboxes_and_password_columns isn't all that different.

          On using a bitfield instead of a boolean: if you only need a single bit from that bitfield (integer, I guess) to display a single checkbox, then that would be a simple change. Creating several columns of checkboxes (one for each bit in the field) is going to be more involved... Which do you need?

          1 Reply Last reply
          0
          • C Offline
            C Offline
            confused
            wrote on last edited by
            #5

            I need a single feild for each row just to show if the record is active or not, then it will be filtered on that, where only the checked/actives ones are shown unless a checkbox on my window is checked then all the records will be shown.

            1 Reply Last reply
            0
            • C Offline
              C Offline
              confused
              wrote on last edited by
              #6

              I had seen your code but only that 1st page I just now found the sample project. I dont have a tree though I am just pulling in a database from SQL so hopefully that will make it simpler and I currently have the field I need to be the checkbox set as a bit type.

              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