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. Row selection
Forum Updated to NodeBB v4.3 + New Features

Row selection

Scheduled Pinned Locked Moved General and Desktop
qabstracttablemqt5.4c++qtableviewrowselection
3 Posts 2 Posters 1.5k 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.
  • S Offline
    S Offline
    sigsevg
    wrote on 26 Jun 2015, 07:11 last edited by
    #1

    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

    1 Reply Last reply
    0
    • S Offline
      S Offline
      SGaist
      Lifetime Qt Champion
      wrote on 26 Jun 2015, 21:25 last edited by
      #2

      Hi and welcome to devnet,

      Do you mean this ?

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0
      • S Offline
        S Offline
        sigsevg
        wrote on 29 Jun 2015, 06:24 last edited by
        #3

        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;
        }
        
        1 Reply Last reply
        0

        2/3

        26 Jun 2015, 21:25

        • Login

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