Results 1 to 3 of 3

Thread: QTableWidget->items

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #2
    Join Date
    Apr 2009
    Location
    Valencia (Spain)
    Posts
    245
    Qt products
    Qt4
    Platforms
    Symbian S60
    Thanks
    38
    Thanked 19 Times in 19 Posts

    Default Re: QTableWidget->items

    you can use rowCount () and columnCount(); two for and add the item to a list.

    Qt Code:
    1. int iColumns = my_table.columnCount();
    2. int iRows = my_table.rowCount();
    3. QList<QWidgetItem*> myList;
    4.  
    5. for(int i = 0; i < iRows; ++i)
    6. {
    7. for(int j = 0; j < iColumn; ++j)
    8. {
    9. QTableWidgetItem* pWidget = my_table->item(i, j);
    10. myList.append(pWigdet);
    11. pWidget = 0;
    12. }
    13. }
    To copy to clipboard, switch view to plain text mode 


    I don't really understand what "const QMimeData * data" is about and why i can't just get a full QList as easily as the selectedItems() method does.
    Well, you can call "items" without attributes.

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

    QT Assistant says "If the object was not created by a QTreeWidget in the same process, the list is empty.", maybe that's why the function is not working in your code. Anyway, the first solution should work.
    Last edited by jano_alex_es; 8th October 2009 at 12:47.

Similar Threads

  1. QComboBox in QTableWidget : display troubles.
    By Nyphel in forum Qt Programming
    Replies: 2
    Last Post: 14th October 2007, 00:29
  2. Select columns from a QTableWidget
    By toglez in forum Qt Programming
    Replies: 10
    Last Post: 7th October 2007, 16:15
  3. QTableWidget (resizing rows, turning off selection, etc.)
    By kiss-o-matic in forum Qt Programming
    Replies: 6
    Last Post: 11th January 2007, 02:57
  4. QTableWidget editing question
    By Trasmeister in forum Qt Programming
    Replies: 1
    Last Post: 20th September 2006, 19:46
  5. Replies: 6
    Last Post: 5th March 2006, 22:05

Tags for this Thread

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.