QTableView Checkbox without label



  • 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.



  • @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?



  • 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;
    }
    

Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.