Nominate our 2022 Qt Champions!

[SOLVED] QListWidget InternalMove adds children

  • Hey there,

    I experienced a strange behavior of my QListWidget. Therefore I prepared this example.

    #ifndef LISTWIDGET_H
    #define LISTWIDGET_H

    #include <QListWidget>
    #include <QDebug>

    class ListWidget : public QListWidget

    ListWidget(QWidget *parent = 0);

    public slots:
    void rowsMoved(QModelIndex,int,int,QModelIndex,int);

    #endif // LISTWIDGET_H


    #include "listwidget.h"

    ListWidget::ListWidget(QWidget *parent)
    : QListWidget(parent)
    this->addItem("Item 1");
    this->addItem("Item 2");

    this->setDragDropMode( QAbstractItemView::InternalMove );
    connect( this->model(),


    void ListWidget::rowsMoved(QModelIndex,int,int,QModelIndex,int)
    qDebug() << this->children().count();

    If I start this and move the two items around, every time the children count raises by one. Is this expected behaviour? If yes, could someone explain me why?

  • Lifetime Qt Champion


    It doesn't look like an expected behavior. What version of Qt are you using ?

  • Hey, I'm using Qt 5.2.1.

  • Lifetime Qt Champion

    Sorry for the late reply

    Can you try again with 5.3 ?

    If this still happens, then have a look at the "bug report system": to see if it's something known. If not please open a new report providing a minimal compilable example that shows the behavior

  • Tried it with 5.3, still the same. Search for a while at the "bug report system" but didn't find anything related to this. Therefore I openend a new "report":

    I hope I did this the right way, as it is the first time I reported something.

  • Lifetime Qt Champion

    It's missing the pro file and it'll be nicer in a compressed archive (e.g. zip), otherwise, looks good :)

Log in to reply