Results 1 to 3 of 3

Thread: How can I delete several rows from QTableWidget at the same time?

  1. #1
    Join Date
    Apr 2009
    Posts
    132
    Thanks
    67
    Thanked 6 Times in 5 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Wink How can I delete several rows from QTableWidget at the same time?

    Hi dudes!


    I have a QTableWidget, and using:
    QList<QTableWidgetSelectionRange> ranges=ui.tableWidgetTextureLibrary->selectedRanges();

    I know what rows are selected (indexes), but obviusly I can't do
    ui.tableWidgetTextureLibrary->removeRow(row);

    Because once I do it, my rows to delete list, is not valid.

    Does anyone have any suggestion?

    I guess I colud do something using an auxiliar struct... But must be an easier way.

    Thanks for help.

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

    Default Re: How can I delete several rows from QTableWidget at the same time?

    You can start deleting from the last row. In that case the indexes will stay valid.

    Or you can probably just delete the items returned by QTableWidget::selectedItems() using qDeleteAll().
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


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

    ricardo (13th May 2009)

  4. #3
    Join Date
    Apr 2009
    Posts
    132
    Thanks
    67
    Thanked 6 Times in 5 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: How can I delete several rows from QTableWidget at the same time?

    Used sorted version and evidently worked.

    I don't know why I didn't have that idea.

    Thanks a lot for your help.

Similar Threads

  1. Copy row(s) from QTableWidget
    By allensr in forum Qt Programming
    Replies: 10
    Last Post: 1st February 2017, 08:59
  2. QtableWidget that don't accept drop item between rows?
    By sergiomar73 in forum General Programming
    Replies: 3
    Last Post: 15th October 2010, 21:55
  3. QTableWidget sorting with hidden rows
    By alex140773 in forum Qt Programming
    Replies: 0
    Last Post: 8th July 2008, 12:35
  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
  •  
Qt is a trademark of The Qt Company.