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. QTableView Checkbox without label
Forum Updated to NodeBB v4.3 + New Features

QTableView Checkbox without label

Scheduled Pinned Locked Moved Unsolved General and Desktop
3 Posts 2 Posters 1.4k Views 2 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.
  • H Offline
    H Offline
    Hans Hansen
    wrote on 13 Dec 2016, 09:40 last edited by
    #1

    Hello,
    I use an table model on an table view.
    But how can I display an editable checkbox without the label.
    Are the only way to use an delegate?

    Current I use the Qt::CheckStateRole for display and Qt::ItemIsUserCheckable|Qt::ItemIsEnabled; for flags.

    Thanks for any ideas.

    V 1 Reply Last reply 13 Dec 2016, 10:36
    0
    • H Hans Hansen
      13 Dec 2016, 09:40

      Hello,
      I use an table model on an table view.
      But how can I display an editable checkbox without the label.
      Are the only way to use an delegate?

      Current I use the Qt::CheckStateRole for display and Qt::ItemIsUserCheckable|Qt::ItemIsEnabled; for flags.

      Thanks for any ideas.

      V Offline
      V Offline
      VRonin
      wrote on 13 Dec 2016, 10:36 last edited by
      #2

      @Hans-Hansen said in QTableView Checkbox without label:

      Current I use the Qt::CheckStateRole for display

      I think this is the problem. are you overriding data() in your model? if so could you post that code?

      "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

      H 1 Reply Last reply 18 Dec 2016, 10:30
      0
      • V VRonin
        13 Dec 2016, 10:36

        @Hans-Hansen said in QTableView Checkbox without label:

        Current I use the Qt::CheckStateRole for display

        I think this is the problem. are you overriding data() in your model? if so could you post that code?

        H Offline
        H Offline
        Hans Hansen
        wrote on 18 Dec 2016, 10:30 last edited by Hans Hansen
        #3

        Here the code of the data function for the cell.

        switch(role)
        {
          case Qt::DisplayRole:
        	switch (index.column())
        	{
                  ....
                 default:
                   return QVariant();
                  break;
                }
           case Qt::CheckStateRole:
            {
            ....
               return Qt::Checked;
              break;
            default:
             return QVariant();
            }
        default:
          return QVariant();
        break;
        }
        
        1 Reply Last reply
        0

        1/3

        13 Dec 2016, 09:40

        • Login

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