PDA

View Full Version : this->selectedItems() or this->selectedIndexes() ???



migel
1st June 2011, 22:32
I need to get all selected items in QTableWidget and getting this error


QList<QTableWidgetItem *> items = this->selectedItems();

error: '((QTableWidget*)this)->QTableWidget::selectedItems' cannot be used as a function

when I try


QList<QTableWidgetItem *> items = this->selectedItems;

it crashes on items.size(); or items.at(0)

It works only if I use this->selectedIndexes(), but why can't use selectedItems() and what about selectedRanges() ??

Santosh Reddy
1st June 2011, 23:14
The correct way to get the list of all the selected item in QTableWidget

QList<QTableWidgetItem*> items = this->selectedItems();

Is your class ("this") a subclass of QTableWidget?

Post definition of "this" class.

What is the error when you use selectedItems()?

migel
2nd June 2011, 17:10
obviously I was doing something wrong, its working now and no idea what was the fixed. sorry, and thanks for the tip

Lykurg
2nd June 2011, 18:08
Maybe you had declared a (member) variable called selectedItems?

migel
5th June 2011, 21:59
Yes , that exactly what happen