Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Update: Forum Guidelines & Code of Conduct

    Qt MSSQL check box

    General and Desktop
    2
    6
    2254
    Loading More Posts
    • 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
      confused last edited by

      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 Reply Quote 0
      • A
        andre last edited by

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

        1 Reply Last reply Reply Quote 0
        • C
          confused last edited by

          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 Reply Quote 0
          • A
            andre last edited by

            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 Reply Quote 0
            • C
              confused last edited by

              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 Reply Quote 0
              • C
                confused last edited by

                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 Reply Quote 0
                • First post
                  Last post