Results 1 to 3 of 3

Thread: QTableView: Select multiple rows?

  1. #1
    Join Date
    Oct 2010
    Location
    Earth
    Posts
    50
    Thanks
    3
    Qt products
    Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default QTableView: Select multiple rows?

    Hi all,

    I have a QTableView and need more than one row selected.

    Qt Code:
    1. void QTableView::selectRow(int row)
    To copy to clipboard, switch view to plain text mode 

    selects one row olny, and

    Qt Code:
    1. ui->tableView->selectRow(0);
    2. ui->tableView->selectRow(1);
    3. ui->tableView->selectRow(2);
    To copy to clipboard, switch view to plain text mode 

    selects row 3 only!

    Is there a way to select more than one row together?

    Thx!
    Chris

  2. #2
    Join Date
    Jul 2009
    Location
    Enschede, Netherlands
    Posts
    462
    Thanked 69 Times in 67 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QTableView: Select multiple rows?

    You have to set the selection mode to the appropriate value. See the documentation.

    I'm not exactly sure if selectRow() will keep the other rows selected. If not, you'll have to learn about the selectionModel() (QItemSelectionModel).
    Horse sense is the thing that keeps horses from betting on people. --W.C. Fields

    Ask Smart Questions

  3. The following user says thank you to franz for this useful post:

    realdarkman71 (10th December 2010)

  4. #3
    Join Date
    Oct 2010
    Location
    Earth
    Posts
    50
    Thanks
    3
    Qt products
    Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: QTableView: Select multiple rows?

    Qt Code:
    1. tableView->setSelectionMode(QAbstractItemView::MultiSelection);
    To copy to clipboard, switch view to plain text mode 

    that's it! Thanks for the hint!

Similar Threads

  1. QFileDialog select multiple directories
    By bepaald in forum Newbie
    Replies: 4
    Last Post: 15th May 2012, 06:17
  2. Select multiple curves
    By aimsc in forum Qwt
    Replies: 2
    Last Post: 30th October 2009, 11:45
  3. Select multiple files from QFileDialog
    By jiveaxe in forum Qt Programming
    Replies: 6
    Last Post: 16th February 2009, 15:57
  4. QTreeView and multi-select of rows
    By QPlace in forum Qt Programming
    Replies: 1
    Last Post: 27th October 2008, 03:32
  5. QTableWidget - Select multiple rows.
    By wally in forum Qt Programming
    Replies: 2
    Last Post: 21st October 2008, 18:15

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.