Results 1 to 7 of 7

Thread: Retrieve userData of a comboBox item

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Aug 2007
    Posts
    244
    Qt products
    Qt4
    Platforms
    Unix/X11
    Thanks
    42
    Thanked 8 Times in 8 Posts

    Default Re: Retrieve userData of a comboBox item

    I already tried it but returns text.

    Regards
    Giuseppe CalÃ

  2. #2
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts

    Default Re: Retrieve userData of a comboBox item

    And what/how did you add as user data? May we see the addItem() statement?
    J-P Nurmi

  3. #3
    Join Date
    Aug 2007
    Posts
    244
    Qt products
    Qt4
    Platforms
    Unix/X11
    Thanks
    42
    Thanked 8 Times in 8 Posts

    Default Re: Retrieve userData of a comboBox item

    sample code:

    Qt Code:
    1. QString bookTitle = "Beginning Joomla!";
    2. QString isbn13String = "978-1590598481";
    3. titleComboBox->addItem(bookTitle, isbn13String);
    To copy to clipboard, switch view to plain text mode 

    Thanks
    Giuseppe CalÃ

  4. #4
    Join Date
    Feb 2006
    Location
    Romania
    Posts
    2,744
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows
    Thanks
    8
    Thanked 541 Times in 521 Posts

    Default Re: Retrieve userData of a comboBox item

    In this case use :
    Qt Code:
    1. QString data = titleComboBox->itemData(0).toString();
    To copy to clipboard, switch view to plain text mode 

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

    jiveaxe (23rd August 2007)

  6. #5
    Join Date
    Aug 2007
    Posts
    244
    Qt products
    Qt4
    Platforms
    Unix/X11
    Thanks
    42
    Thanked 8 Times in 8 Posts

    Default Re: Retrieve userData of a comboBox item

    Ok marcel, now works.

    Thank you
    Giuseppe CalÃ

Similar Threads

  1. Replies: 8
    Last Post: 15th May 2007, 09:21
  2. Can Qtable Item be a comboBox?
    By iGoo in forum Qt Programming
    Replies: 2
    Last Post: 4th August 2006, 09:58

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.