Results 1 to 1 of 1

Thread: How to get list of selected rows during multiple selection in Qtableview?

  1. #1
    Join Date
    Nov 2015
    Posts
    8
    Qt products
    Qt5
    Platforms
    Unix/X11

    Default How to get list of selected rows during multiple selection in Qtableview?

    I have the data in Qtableview, where my task is, when ever I do multiple
    selection of rows I want the content of all selected rows. or at least I
    would like to know what are the row numbers I have selected.

    I am trying with this code but I am getting 'Zero' every time even though I don't select any row.

    If I give Printf() after the right curly braces it's printing 'zero ' every time.

    and If I print() it before right curly braces nothing is getting printed

    ui->xvalue->setSelectionMode(QAbstractItemView::ExtendedSelec tion);
    ui->xvalue->setSelectionBehavior(QAbstractItemView::SelectRow s);
    ui->xvalue->show(); QModelIndexList indexList = ui->xvalue->selectionModel()->selectedIndexes(); int row;
    foreach (QModelIndex index, indexList){

    row = index.row(); }
    printf("\n%d\n",row);


    I even tried this but no use I am not getting the answer


    QItemSelectionModel* selectionModel =this-> ui->xvalue->selectionModel();
    QModelIndexList selected = selectionModel->selectedIndexes(); i
    nt num;
    for(int i=0; i< selected.count();i++)
    {
    QModelIndex index = selected.at(i);
    qDebug()<< index.row();
    num = index.row();

    printf("selected row is %d", num);
    }
    Last edited by allulks; 14th November 2015 at 09:20.

Similar Threads

  1. Remove selected rows from a QTableView
    By niko in forum Qt Programming
    Replies: 4
    Last Post: 3rd March 2016, 13:49
  2. How to remove a multiple selection of rows
    By aguleo in forum Newbie
    Replies: 3
    Last Post: 11th December 2013, 04:53
  3. Moving up and down the selected rows in a QTableview
    By Raghaw in forum Qt Programming
    Replies: 0
    Last Post: 28th January 2013, 12:04
  4. iterating selected rows in a qtableview
    By JeanC in forum Qt Programming
    Replies: 2
    Last Post: 19th January 2008, 15:29
  5. Get list of selected rows from QTableView
    By jnk5y in forum Qt Programming
    Replies: 8
    Last Post: 17th February 2006, 17:59

Tags for this Thread

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.