Results 1 to 6 of 6

Thread: Remove Selected Rows form QTablewidget [unsolved]

  1. #1
    Join Date
    Jul 2006
    Posts
    36
    Thanks
    8
    Thanked 1 Time in 1 Post
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Remove Selected Rows form QTablewidget [unsolved]

    hi all

    how can i Remove selected Rows form QTablewidget?

    Last edited by QiT; 1st April 2007 at 17:49.
    power of mind > mind of power

  2. #2
    Join Date
    Jan 2006
    Location
    travelling
    Posts
    1,116
    Thanks
    8
    Thanked 127 Times in 121 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Remove Rows form QTablewidget

    Quote Originally Posted by QiT View Post
    hi all

    how can i Remove selected Rows form QTablewidget?

    QTableWidget::removeRow(int)...

    Use the docs Luke, use the docs.
    Current Qt projects : QCodeEdit, RotiDeCode

  3. #3
    Join Date
    Jul 2006
    Posts
    36
    Thanks
    8
    Thanked 1 Time in 1 Post
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: Remove Rows form QTablewidget

    I know that, but i sayed "selected rows"
    power of mind > mind of power

  4. #4
    Join Date
    Jan 2006
    Location
    travelling
    Posts
    1,116
    Thanks
    8
    Thanked 127 Times in 121 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Remove Rows form QTablewidget

    Quote Originally Posted by QiT View Post
    I know that, but i sayed "selected rows"
    Why don't you like these ?

    Of course the loop and computations is left to you but I don't see the problem here...

    Here comes a minimalistic implementation which assumes only one selection (which does not mean one colum/row/cell however...)
    Qt Code:
    1. void MyTableWidget::removeSelected()
    2. {
    3. QList<QTableWidgetSelectionRange> ranges = selectedRanges();
    4.  
    5. if ( ranges.isEmpty() )
    6. return;
    7.  
    8. int begin = ranges.at(0).topRow(),
    9. count = ranges.at(0).rowCount();
    10.  
    11. do
    12. {
    13. removeRow(begin);
    14. }while ( --count );
    15.  
    16. }
    To copy to clipboard, switch view to plain text mode 
    The complexer implementation is left as an exercise to the reader.
    Last edited by fullmetalcoder; 1st April 2007 at 18:10. Reason: reformatted to look better
    Current Qt projects : QCodeEdit, RotiDeCode

  5. #5
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Remove Rows form QTablewidget

    Quote Originally Posted by fullmetalcoder View Post
    Use the docs Luke, use the docs.
    Hey! That's my quote! Isn't there a copyright law here or something?

  6. #6
    Join Date
    Jan 2006
    Location
    travelling
    Posts
    1,116
    Thanks
    8
    Thanked 127 Times in 121 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Remove Rows form QTablewidget

    Quote Originally Posted by wysota View Post
    Hey! That's my quote! Isn't there a copyright law here or something?
    Sure! Apologies for having forgotten to put quotation marks... Maybe you can do it yourself.
    Current Qt projects : QCodeEdit, RotiDeCode

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. Replies: 6
    Last Post: 13th February 2014, 12:46
  3. Text under the Icon
    By QiT in forum Newbie
    Replies: 3
    Last Post: 1st April 2007, 17:42
  4. QTableWidget (resizing rows, turning off selection, etc.)
    By kiss-o-matic in forum Qt Programming
    Replies: 6
    Last Post: 11th January 2007, 01:57
  5. Replies: 6
    Last Post: 5th March 2006, 21:05

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.