Row selection



  • Hi all,

    I'd like to allow row selection by clicking vertical header and prevent cell and column selection. How can I do that ?

    Thanks


  • Lifetime Qt Champion

    Hi and welcome to devnet,

    Do you mean this ?



  • Hi, thanks for the reply. Yes, I set that flag to true but I can select a row by clicking indivual cell or horizontal header. I've overriden flags function in my model if I remove isSelectable flag i can't select anything.

    Qt::ItemFlags TableModel::flags(const QModelIndex &index) const
    {
        if(!index.isValid())
        {
            return Qt::ItemIsEnabled;
        }
        if(index.column() == 1)
        {
            if(modelList.at(index.row()).isArray)
            {
                return Qt::ItemIsEnabled | Qt::ItemIsUserCheckable | Qt::ItemIsEditable;
            }
            return Qt::ItemIsEnabled | Qt::ItemIsUserCheckable;
        }
        return Qt::ItemIsEnabled | Qt::ItemIsEditable | Qt::ItemIsSelectable;
    }
    


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