Results 1 to 2 of 2

Thread: QListWidget item value extracted

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Dec 2010
    Posts
    23
    Qt products
    Qt3 Qt4
    Platforms
    MacOS X Windows

    Default QListWidget item value extracted

    I cannot figure out how to extract the value of a selected item from a QListWidget.

    For example, say I have a list with three items "Hello", "Goodbye", "Goodmorning".

    The user interface has a push button, the QListWidget and a label.
    I have a slot connected to the clicked() button in which I want the selected item from the list widget, that value is put into the value of the label using ui->label->setText(value); What I don't understand is how to extract the value from the selected item in the QListWidget. Thank you in advance.

  2. #2
    Join Date
    Jan 2006
    Location
    Belgium
    Posts
    1,938
    Thanked 268 Times in 268 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows
    Wiki edits
    20

    Default Re: QListWidget item value extracted

    Assuming that you can only select one item in the list, you can use:
    http://doc.qt.nokia.com/4.7/qlistwid...ml#currentItem

    But before using it, check if the pointer is valid. I think the first time the program starts, there's no item selected.

Similar Threads

  1. QListWidget Item
    By csvivek in forum Qt Programming
    Replies: 1
    Last Post: 15th June 2008, 09:02
  2. remove item from QListWidget
    By yushinee in forum Newbie
    Replies: 3
    Last Post: 2nd October 2007, 20:40
  3. QListWidget and selecting an item
    By invictus in forum Newbie
    Replies: 4
    Last Post: 19th June 2007, 11:59
  4. Reg - add item in QListWidget
    By suresh in forum Newbie
    Replies: 1
    Last Post: 1st September 2006, 17:52
  5. extract item from QListWidget
    By impeteperry in forum Qt Programming
    Replies: 2
    Last Post: 13th May 2006, 19:41

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.