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. How diff MousePress and shift/ctrl+MousePress?
Forum Updated to NodeBB v4.3 + New Features

How diff MousePress and shift/ctrl+MousePress?

Scheduled Pinned Locked Moved Solved General and Desktop
2 Posts 1 Posters 1.1k Views
  • 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.
  • qazaq408Q Offline
    qazaq408Q Offline
    qazaq408
    wrote last edited by qazaq408
    #1

    QTable +model;

    there is a request that if user click a item in first column,the whole row must be selected,but if user click other item( not belong first column),it only select a item.

    so i implement the function like this

    connect(tableview ,SIGNAL(clicked(const QModelIndex&)),this,SLOT(select_row(const QModelIndex&)));
    
    void MyWidget::select_row(const QModelIndex&){
        if(index.column() ==0)
            tableview ->selectRow(index.row());
    }
    

    it worked,but there are some another request. The first ,user need shift+MousePressed to select more rows,I press "SHIFT" and the MousePress three item int first column(row 0,1,3),but four rows(0,1,2,3) are selected, i swear i never clicke QModelIndex(0,3)...

    And another problem,when i select four rows(row index:0,1,2,3), then i hope "CTRL"+MousePressed third item to cancel the selection,but third row is always selected. I can't cancel selection by "CTRL"+MousePressed.

    1 Reply Last reply
    0
    • qazaq408Q Offline
      qazaq408Q Offline
      qazaq408
      wrote last edited by
      #2

      i got it

      event->modifiers() & Qt::ShiftModifier
      
      1 Reply Last reply
      0
      • qazaq408Q qazaq408 has marked this topic as solved

      • Login

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