Results 1 to 9 of 9

Thread: Selecting somes cells from a QTableWidget

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Selecting somes cells from a QTableWidget

    The first argument of the item() method is the row.
    Get the item for each cell you are interested in and read its data.

    Cheers,
    _

  2. #2
    Join Date
    Jan 2012
    Posts
    83
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Selecting somes cells from a QTableWidget

    Thanks Anda_Skoa for your reply.

    I am using a loop to accees the cells of my column.
    I have added the following condition in my loop:

    Qt Code:
    1. QTableWidgetItem *valueOfMycell;
    2. if(valueOfMyCell->isSelected())
    3. {
    4. }
    To copy to clipboard, switch view to plain text mode 

    The output (from qDebug) ist excatly the values I am looking for, but the program crasches down.
    When I removed the line 2, I have all values of my culumn, including those deselected.
    I now know that the condition of the line 2 is not appropriate, but I am wondering if there is another condition which matches with this case.
    I would appreciate any help.

    Many thanks in advance.

  3. #3
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Selecting somes cells from a QTableWidget

    The condition looks good, it is more likely that you have an error elsewhere, especially if "the program crashes down" means it unexpectedly terminates.

    Alternatively look at QTableWidget::selectedItems() to directly get the selected cells.

    Cheers,
    _

  4. #4
    Join Date
    Jan 2012
    Posts
    83
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Selecting somes cells from a QTableWidget

    Many thanks Anda_Skoa for your help.

    I have successfully fixed the problem using QTableWidget::selectedItems() as you have specified.

    For me is this problem solved.

    Many thanks one more time.

Similar Threads

  1. QTableWidget exclusive cells
    By bwnicewo in forum Qt Programming
    Replies: 1
    Last Post: 30th May 2012, 00:25
  2. How to display cut cells in QTableWidget
    By danblanks in forum Qt Programming
    Replies: 0
    Last Post: 16th February 2011, 21:42
  3. [How to ?] Writing QTableWidget cells.
    By Rewo in forum Newbie
    Replies: 6
    Last Post: 4th April 2010, 11:00
  4. Merging cells in QTableWidget
    By lyucs in forum Newbie
    Replies: 1
    Last Post: 22nd January 2010, 19:15
  5. Focus of cells in a QTableWidget
    By SailinShoes in forum Qt Programming
    Replies: 4
    Last Post: 9th June 2008, 08:19

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.