Results 1 to 2 of 2

Thread: QComboBox addItems() inserts QStringList twice

  1. #1
    Join Date
    Dec 2010
    Posts
    76
    Thanks
    13
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Angry QComboBox addItems() inserts QStringList twice

    I have an application where I insert items into a QStringList stringList and then when filling in the QComboBox I use comboBox->addItems(stringList) to populate the drop down box.

    I am populating the QStringList like so:

    stringList.append("First");
    stringList.append("Second");
    // and so on

    I populate the combo box like so:

    comboBox->addItems(stringList);

    When I go to click the drop down arrow, I see the following list of items in the combo box:

    First
    Second
    First
    Second

    Why is the combo box being populated twice with the QStringList?

    Thanks for any help!!

  2. #2
    Join Date
    Jan 2006
    Location
    Sta. Eugènia de Berga (Vic - Barcelona - Spain)
    Posts
    869
    Thanks
    70
    Thanked 59 Times in 57 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: QComboBox addItems() inserts QStringList twice

    Hi,

    Are you sure that your are not populating the QStringList twice? Or maybe adding the items twice?
    You can call "QComboBox::clear()" before adding the items.
    Òscar Llarch i Galán

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

    jshafferman (3rd January 2012)

Similar Threads

  1. Dragging text/uri-list: Qt inserts garbage
    By drhex in forum Qt Programming
    Replies: 1
    Last Post: 22nd September 2011, 20:45
  2. Add separator to QComboBox using QStringList entries
    By mrknight in forum Qt Programming
    Replies: 3
    Last Post: 26th November 2010, 23:31
  3. QSqlTableModel inserts empty rows
    By Nesbitt in forum Qt Programming
    Replies: 2
    Last Post: 6th August 2008, 12:47
  4. QDataTable Inserts and Updates
    By ederbs in forum Qt Programming
    Replies: 2
    Last Post: 26th October 2006, 23:23
  5. Replies: 7
    Last Post: 2nd June 2006, 12:48

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.