Results 1 to 6 of 6

Thread: QListWidget custom numbering ?

  1. #1
    Join Date
    Sep 2007
    Posts
    36
    Thanks
    5
    Thanked 3 Times in 1 Post

    Thumbs up QListWidget custom numbering ?

    http://doc.trolltech.com/4.4/qlistwidget.html

    The items are always numbered from 0

    Is it possible to add a custom number/string rather than the ones provided by default ?

    Something similar to the select statement in HTML ?


  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QListWidget custom numbering ?

    Do you mean that you would like to pass something different than 0-based index to QListWidget::item()?

  3. #3
    Join Date
    Sep 2007
    Posts
    36
    Thanks
    5
    Thanked 3 Times in 1 Post

    Default Re: QListWidget custom numbering ?

    <select>
    <option value="A001">Alanka</option>
    ..

    I want do something that is similar to a select option in html. It allows the programmer to specify their own index values.

    this too applies for qcombobox.

    It only allows int index starting from 0.

    Is it possible ?

  4. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QListWidget custom numbering ?

    You can use two QMaps to translate indices to keys and vice versa.

  5. #5
    Join Date
    Sep 2007
    Posts
    36
    Thanks
    5
    Thanked 3 Times in 1 Post

    Default Re: QListWidget custom numbering ?

    I will have to create a seperate map that links the model index values with ids comings from database ?

    The combobox i want to use is linked with a db. with one tables ids, name

    I want to show the name in the combo box and the ids as the index value.

    i will have to create a seperate map that links the ids with the int. index of combo box and call the function does that everytime the underlying model changes ?

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

    Default Re: QListWidget custom numbering ?

    You can use QComboBox::setItemData() to make a mapping. I'm not sure what does it have to do with QListWidget...

Similar Threads

  1. Replies: 2
    Last Post: 16th May 2008, 14:39
  2. custom painting in QListWidget
    By Andrew in forum Qt Programming
    Replies: 21
    Last Post: 30th March 2007, 13:16
  3. Replies: 13
    Last Post: 15th December 2006, 11:52

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.