Results 1 to 2 of 2

Thread: extracting a item from a QListWidget question

  1. #1
    Join Date
    Jan 2006
    Location
    Riverside, Rhode Island, USA
    Posts
    245
    Thanks
    52
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Default extracting a item from a QListWidget question

    I have a QListWidget lwFoo whch cantains a column of QString items.
    I double clicked on an item and got an index, but what I want is the item itself. In Ot3 terminalogy the "text"!!!.

    I can't make heads or tails of documentation to do this.
    I would appreciate is if someone could give me the code or explain the documentation in an understandable format.

    I think I found a way
    Qt Code:
    1. QListWidgetItem *wow = lwCurrentList->item ( index );
    2. inputText = wow->text();
    To copy to clipboard, switch view to plain text mode 
    or
    Qt Code:
    1. inputText = lwCurrentList->item ( index ) -> text();
    To copy to clipboard, switch view to plain text mode 
    tsk! tsk! tsk!

    Thanks.
    Last edited by impeteperry; 27th January 2007 at 05:16.

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,368
    Thanks
    3
    Thanked 5,018 Times in 4,794 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: extracting a item from a QListWidget question

    If you have an index you can simply call index.data() to retrieve a QVariant with the data, but the snippet you have written will also work.
    By the way - you could have connected to the itemDoubleClicked() signal to get the actual item right away.

  3. The following user says thank you to wysota for this useful post:

    impeteperry (27th January 2007)

Similar Threads

  1. Replies: 3
    Last Post: 7th November 2006, 08:35
  2. question regarding qlistwidget
    By amulya in forum Qt Programming
    Replies: 1
    Last Post: 6th October 2006, 07:17
  3. Reg - add item in QListWidget
    By suresh in forum Newbie
    Replies: 1
    Last Post: 1st September 2006, 17:52
  4. extract item from QListWidget
    By impeteperry in forum Qt Programming
    Replies: 2
    Last Post: 13th May 2006, 19:41
  5. keypress while editing an item in QListWidget
    By Beluvius in forum Qt Programming
    Replies: 3
    Last Post: 4th April 2006, 09:56

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.