Results 1 to 2 of 2

Thread: Highlight item in the list in accordance to text input

  1. #1
    Join Date
    Jan 2014
    Posts
    9
    Qt products
    Platforms
    MacOS X Unix/X11

    Default Highlight item in the list in accordance to text input

    I am trying to highlight the item in my list upon the input of the text in the LineEdit but however, not only am I unable to get it to work but it also does not highlights the item in the List. Am I writing it wrong somewhere? Any advices?

    Qt Code:
    1. fruitsList = QListWidget()
    2. list01 = ['Apple','Pear','Orange','Grape','Lychee']
    3. self.fruitsList.addItems(list01)
    4.  
    5. textInput = QLineEdit()
    6. fruitTxt = str(textInput)
    7.  
    8. self.connect(self.textInput,('returnPressed()'), self.updateSelect)
    9.  
    10. def updateSelect(self):
    11. self.fruitsList.findItems(str(fruitTxt), flags = Qt.MatchExactly)
    12. self.fruitsList.setCurrentIndex(0)
    To copy to clipboard, switch view to plain text mode 

  2. #2
    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: Highlight item in the list in accordance to text input

    findItems() returns you a list of the items matching your search string.

    In your case you would then iterate over that list and call setSelected(true)

    Cheers,
    _

Similar Threads

  1. Highlight an item in QCombobox by text color
    By AlekseyK in forum Qt Programming
    Replies: 6
    Last Post: 18th March 2019, 21:31
  2. How to highlight a menu item by program input
    By horbi in forum Qt Programming
    Replies: 1
    Last Post: 7th August 2015, 09:37
  3. Replies: 1
    Last Post: 14th November 2012, 21:00
  4. Designer plugin & dynamic value list for text input
    By janus in forum Qt Programming
    Replies: 0
    Last Post: 4th April 2009, 12:41
  5. Highlight text in list box
    By Sheetal in forum Qt Tools
    Replies: 7
    Last Post: 9th April 2007, 11:24

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