Results 1 to 13 of 13

Thread: Selected Rows moveUp/moveDown in QTableWidget

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Sep 2010
    Posts
    8
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Selected Rows moveUp/moveDown in QTableWidget

    Hello folks,
    I've a quick question. I need to moveUp selected rows in tablewidget.
    I guess miss something, not working!


    Qt Code:
    1. void MainWindow::moveUp()
    2. {
    3. QItemSelectionModel *smodel= ui.tableView->selectionModel();
    4. if (smodel==0) {
    5. return;
    6. }
    7. QModelIndexList selectionList =smodel->selectedRows();
    8. QModelIndex idx = selectionList.first();
    9. int row=idx.row()-1;
    10. if (row<0) {
    11. row=0;
    12. }
    13. QModelIndex previous=model->index(row,idx.column());
    14. ui.tableView->selectionModel()->select(previous, QItemSelectionModel::ClearAndSelect | QItemSelectionModel::Rows);
    15. ui.tableView->setCurrentIndex(model->index(row,idx.column()));
    16. ui.tableView->scrollTo(ui.tableView->currentIndex());
    17.  
    18. }
    To copy to clipboard, switch view to plain text mode 
    Last edited by wysota; 13th September 2010 at 18:42.

Similar Threads

  1. Remove selected rows from a QTableView
    By niko in forum Qt Programming
    Replies: 4
    Last Post: 3rd March 2016, 12:49
  2. Show selected rows
    By mpi in forum Qt Programming
    Replies: 3
    Last Post: 23rd June 2010, 01:59
  3. removing of selected rows
    By MrShahi in forum Qt Programming
    Replies: 4
    Last Post: 10th June 2008, 15:05
  4. Replies: 5
    Last Post: 2nd April 2007, 08:57
  5. Get list of selected rows from QTableView
    By jnk5y in forum Qt Programming
    Replies: 8
    Last Post: 17th February 2006, 16: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
  •  
Qt is a trademark of The Qt Company.