PDA

View Full Version : Remove Selected Rows form QTablewidget [unsolved]



QiT
1st April 2007, 18:15
hi all

how can i Remove selected Rows form QTablewidget?

:confused:

fullmetalcoder
1st April 2007, 18:31
hi all

how can i Remove selected Rows form QTablewidget?

:confused:

QTableWidget::removeRow(int)...

Use the docs Luke, use the docs. :rolleyes:

QiT
1st April 2007, 18:35
I know that, but i sayed "selected rows"

fullmetalcoder
1st April 2007, 19:09
I know that, but i sayed "selected rows"
Why don't you like these ?

QTableWidget::selectedItems()
QTableWidget::selectedRanges()
Of course the loop and computations is left to you but I don't see the problem here... :p

Here comes a minimalistic implementation which assumes only one selection (which does not mean one colum/row/cell however...)


void MyTableWidget::removeSelected()
{
QList<QTableWidgetSelectionRange> ranges = selectedRanges();

if ( ranges.isEmpty() )
return;

int begin = ranges.at(0).topRow(),
count = ranges.at(0).rowCount();

do
{
removeRow(begin);
}while ( --count );

}
The complexer implementation is left as an exercise to the reader. :)

wysota
1st April 2007, 19:21
Use the docs Luke, use the docs. :rolleyes:

Hey! That's my quote! Isn't there a copyright law here or something? :cool:

fullmetalcoder
2nd April 2007, 09:57
Hey! That's my quote! Isn't there a copyright law here or something? :cool:
Sure! Apologies for having forgotten to put quotation marks...:o Maybe you can do it yourself.