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. Where does role variable for setData() functions get determined? (for debugging)

Where does role variable for setData() functions get determined? (for debugging)

Scheduled Pinned Locked Moved Solved General and Desktop
3 Posts 2 Posters 345 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.
  • A Offline
    A Offline
    andi456
    wrote on last edited by
    #1

    Please correct me if i'm wrong. From what i've figured out so far, it seems to me that the Qt::ItemFlags returned by the flags() function determine the role for the setData() function. As a result setData() not receiving Qt::CheckStateRole indicates that something's wrong with the flags() function. Is this correct?

    If so, how could i possibly debug this.

    1 Reply Last reply
    0
    • Christian EhrlicherC Offline
      Christian EhrlicherC Offline
      Christian Ehrlicher
      Lifetime Qt Champion
      wrote on last edited by
      #2

      @andi456 said in Where does role variable for setData() functions get determined? (for debugging):

      result setData() not receiving Qt::CheckStateRole indicates that something's wrong with the flags() function. Is this correct?

      No. Flags don't have something to do with setData().

      When you want to have a user-checkable checkbox in your view, flags() has to return Qt::ItemIsUserCheckable and data() should return something meaningful for Qt::CheckStateRole.

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

      A 1 Reply Last reply
      0
      • Christian EhrlicherC Christian Ehrlicher

        @andi456 said in Where does role variable for setData() functions get determined? (for debugging):

        result setData() not receiving Qt::CheckStateRole indicates that something's wrong with the flags() function. Is this correct?

        No. Flags don't have something to do with setData().

        When you want to have a user-checkable checkbox in your view, flags() has to return Qt::ItemIsUserCheckable and data() should return something meaningful for Qt::CheckStateRole.

        A Offline
        A Offline
        andi456
        wrote on last edited by
        #3

        @Christian-Ehrlicher Well, maybe I expressed myself a little bit clumsily, but it was indeed my implementation of the flags() function which caused the problem - a momentary lapse of reason, so to say. If i understand you correctly, then there's one more step involved: from flags() to data() to setData().

        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