Results 1 to 3 of 3

Thread: qlistwidget shows only one item

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Nov 2010
    Location
    Budapest, Hungary
    Posts
    125
    Thanks
    17
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default qlistwidget shows only one item

    Hi,

    my problem is that I have a QListWidget on my gui and it cannot show more than one item. What have I ticked/set accidentally?! It worked before just fine! Now I'm trying to fill it simply from the Mainindow's contructor like this:
    Qt Code:
    1. ui->listWidget_meta->addItem("one");
    2. ui->listWidget_meta->addItem("two");
    To copy to clipboard, switch view to plain text mode 

    and the result is that I can't see "one", only "two" - as on the attached image. No matter how many items I add, always the last one is there.

    What's more I cannot click on the item. It is not enabled (as you can see it is not grey), but simply unchoseable.
    Attached Images Attached Images
    Last edited by szisziszilvi; 18th August 2011 at 13:31.
    Szilvi

  2. #2
    Join Date
    Jul 2011
    Posts
    18
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: qlistwidget shows only one item

    I went with the QListWidgetItem options just because i found using Items was easier for my application.

    I would go this route or using QStringList, just depends on your requirements.

    Qt Code:
    1. _list->addItem( i );
    2. _list->addItem( j );
    To copy to clipboard, switch view to plain text mode 

    Other things you could do is use currentRow() to see if it is incrementing correctly

  3. #3
    Join Date
    Nov 2010
    Location
    Budapest, Hungary
    Posts
    125
    Thanks
    17
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: qlistwidget shows only one item

    currentRow() returns with the value of -1. This must be because nothing is selected. However as I mentioned before nothing _can_ be selected and I cannot see why.
    I also tried the QListWidget::count() function and it returned with the proper number of the added items. Now where are the rest? I still see only one, the last one, no matter how many I add.
    Szilvi

Similar Threads

  1. Add thousands of item to QListWidget
    By daarsh in forum Qt Programming
    Replies: 3
    Last Post: 13th April 2011, 10:39
  2. QListWidget Item
    By csvivek in forum Qt Programming
    Replies: 1
    Last Post: 15th June 2008, 10:02
  3. Item Selection in QListWidget
    By mclark in forum Qt Programming
    Replies: 2
    Last Post: 12th February 2008, 16:53
  4. Reg - add item in QListWidget
    By suresh in forum Newbie
    Replies: 1
    Last Post: 1st September 2006, 18:52
  5. extract item from QListWidget
    By impeteperry in forum Qt Programming
    Replies: 2
    Last Post: 13th May 2006, 20: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
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.