Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-77294

QListWidget insertItem() Problem

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • Not Evaluated
    • None
    • 5.9.3
    • Widgets: Itemviews
    • None
    • windows 10
    • Windows

    Description

      I call the insertItem()  function of QListWidget to insert a data in the first line,But always insert in the last line.

      My code is as follows:

       

      AreaSelectUnitWidget* pUnit = new AreaSelectUnitWidget(this);   // new a widget

      QListWidgetItem* item = new QListWidgetItem(ui->listWidget);  

      ui->listWidget->insertItem(0,item);    // I want to insert it in the first line every time

      ui->listWidget->setItemWidget(item,pUnit);    // set widget as item 

       

      When  i call the above code as a function several times,my new inserted widget item always inserted in the last line,not  the first line.

      Why doesn't it work?Some people say don't write like that : "new QListWidgetItem(ui->listWidget);", I tried not to use "ui->listWidget" as it parent object,But it still didn't work.Please tell me what should i do?I am a chinese,My english is not good,so please explain it in detail,thanks!

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            qt.team.quick.subscriptions Qt Quick and Widgets Team
            zuoshul zuoshu li
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes