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. QCheckbox overlap with Table item value
Forum Updated to NodeBB v4.3 + New Features

QCheckbox overlap with Table item value

Scheduled Pinned Locked Moved Solved General and Desktop
qcheckboxdelegatedelegatemodelqstandarditemqtableview
3 Posts 2 Posters 666 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.
  • S Offline
    S Offline
    sayan275
    wrote on 4 Jun 2020, 04:18 last edited by
    #1

    I am adding QCheckbox as QStandardItem in QTableView via a delegate class.

    e74c04c4-f6e8-46d5-b2c4-6921274b6607-image.png

    But the value is also getting added and are overlapped.
    As in the image, the value is false, so a unchecked checkbox only should appear. But the value is also getting added below the checkbox

    8e020427-0365-4b9d-b5af-9f8107b59cf2-image.png

    And when we make it checked, true is coming at behind.

    Any suggestion, why the value is also appearing behind the checkbox.

    Regards,
    Sayan

    1 Reply Last reply
    0
    • V Offline
      V Offline
      VRonin
      wrote on 4 Jun 2020, 09:21 last edited by VRonin 6 Apr 2020, 09:25
      #2

      Adding checkboxes does not require custom delegates.
      all you need to do is:

      standardItem->setData(Qt::Unchecked,Qt::CheckStateRole); // makes the checkbox appear
      standardItem->setFlags(standardItem->flags() | Qt::ItemIsUserCheckable); // the user can click on the checkbox to toggle it
      

      P.S.
      Foreseeing your next question: https://forum.qt.io/topic/94049/how-to-center-a-column-with-a-checkbox-in-qtableview

      "La mort n'est rien, mais vivre vaincu et sans gloire, c'est mourir tous les jours"
      ~Napoleon Bonaparte

      On a crusade to banish setIndexWidget() from the holy land of Qt

      S 1 Reply Last reply 4 Jun 2020, 13:32
      4
      • V VRonin
        4 Jun 2020, 09:21

        Adding checkboxes does not require custom delegates.
        all you need to do is:

        standardItem->setData(Qt::Unchecked,Qt::CheckStateRole); // makes the checkbox appear
        standardItem->setFlags(standardItem->flags() | Qt::ItemIsUserCheckable); // the user can click on the checkbox to toggle it
        

        P.S.
        Foreseeing your next question: https://forum.qt.io/topic/94049/how-to-center-a-column-with-a-checkbox-in-qtableview

        S Offline
        S Offline
        sayan275
        wrote on 4 Jun 2020, 13:32 last edited by
        #3

        @VRonin Thanks.
        It worked.
        We have used delegates because we have combobox, lineedit also.
        So we have put check for combobox, not to update via delegate.

        1 Reply Last reply
        0

        3/3

        4 Jun 2020, 13:32

        • Login

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