Results 1 to 4 of 4

Thread: how to perform search in QTableWidget?

  1. #1
    Join Date
    Oct 2011
    Posts
    160
    Thanks
    31
    Qt products
    Qt4
    Platforms
    Windows

    Default how to perform search in QTableWidget?

    hi all,
    I want to perform a search operation in a table widget and want to highlight the row which contains particular word(key used for searching).
    Please somebody tell me is that possible?

  2. #2
    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: how to perform search in QTableWidget?

    Loop through the elements or see QSortFilterProxyModel.

  3. #3
    Join Date
    Oct 2011
    Posts
    160
    Thanks
    31
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: how to perform search in QTableWidget?

    Thank u....
    I tried like this....
    Qt Code:
    1. QList<QTableWidgetItem *> LTempTable =temp->findItems("001",Qt::MatchEndsWith);
    2.  
    3. cout<<"the matched count:"<<LTempTable.count()<<endl;
    4. foreach(rowPtr,LTempTable)
    5. {
    6. rowPtr->setBackground(Qt::red);
    7. }
    To copy to clipboard, switch view to plain text mode 


    But it is highlighting only that particular item, i want to highlight that whole row...
    How can i do that?

  4. #4
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: how to perform search in QTableWidget?

    Put in a for loop and set the background on all items in the same row as the matched item.

    Alternatively you could use the QTableWidget selection with selection mode QAbstractItemView::ExtendedSelection and selection behaviour QAbstractItemView::SelectRows.

  5. The following user says thank you to ChrisW67 for this useful post:

    aurora (5th January 2012)

Similar Threads

  1. Perform an automatic click on a webpage
    By manuelito2459 in forum Newbie
    Replies: 0
    Last Post: 25th December 2011, 22:50
  2. Replies: 5
    Last Post: 27th May 2011, 03:51
  3. Replies: 4
    Last Post: 13th January 2011, 08:58
  4. Perform a cyclic task in a QState
    By schall_l in forum Qt Programming
    Replies: 1
    Last Post: 17th April 2010, 00:18
  5. Replies: 12
    Last Post: 22nd March 2010, 09:59

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
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.