Results 1 to 5 of 5

Thread: this->selectedItems() or this->selectedIndexes() ???

  1. #1
    Join Date
    Apr 2011
    Posts
    132
    Thanks
    14
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default this->selectedItems() or this->selectedIndexes() ???

    I need to get all selected items in QTableWidget and getting this error

    Qt Code:
    1. QList<QTableWidgetItem *> items = this->selectedItems();
    To copy to clipboard, switch view to plain text mode 

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

    when I try

    Qt Code:
    1. QList<QTableWidgetItem *> items = this->selectedItems;
    To copy to clipboard, switch view to plain text mode 

    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() ??

  2. #2
    Join Date
    Mar 2011
    Location
    Hyderabad, India
    Posts
    1,882
    Thanks
    3
    Thanked 452 Times in 435 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows
    Wiki edits
    15

    Default Re: this->selectedItems() or this->selectedIndexes() ???

    The correct way to get the list of all the selected item in QTableWidget
    Qt Code:
    1. QList<QTableWidgetItem*> items = this->selectedItems();
    To copy to clipboard, switch view to plain text mode 

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

    Post definition of "this" class.

    What is the error when you use selectedItems()?

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

    migel (2nd June 2011)

  4. #3
    Join Date
    Apr 2011
    Posts
    132
    Thanks
    14
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: this->selectedItems() or this->selectedIndexes() ???

    obviously I was doing something wrong, its working now and no idea what was the fixed. sorry, and thanks for the tip

  5. #4
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    4,380
    Thanks
    19
    Thanked 1,005 Times in 913 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60
    Wiki edits
    5

    Default Re: this->selectedItems() or this->selectedIndexes() ???

    Maybe you had declared a (member) variable called selectedItems?

  6. #5
    Join Date
    Apr 2011
    Posts
    132
    Thanks
    14
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: this->selectedItems() or this->selectedIndexes() ???

    Yes , that exactly what happen

Similar Threads

  1. QTableWidget::selectedItems()
    By maxpower in forum Qt Programming
    Replies: 3
    Last Post: 29th April 2011, 15:34
  2. QItemSelectionModel::selectedIndexes() fail
    By Stapl in forum Qt Programming
    Replies: 1
    Last Post: 22nd October 2009, 01:54

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.