Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. [SOLVED] QListWidget InternalMove adds children
Forum Updated to NodeBB v4.3 + New Features

[SOLVED] QListWidget InternalMove adds children

Scheduled Pinned Locked Moved General and Desktop
6 Posts 2 Posters 1.8k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • D Offline
    D Offline
    david.luggen
    wrote on last edited by
    #1

    Hey there,

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

    listwidget.h:
    @
    #ifndef LISTWIDGET_H
    #define LISTWIDGET_H

    #include <QListWidget>
    #include <QDebug>

    class ListWidget : public QListWidget
    {
    Q_OBJECT

    public:
    ListWidget(QWidget *parent = 0);

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

    #endif // LISTWIDGET_H
    @

    listwidget.cpp:

    @
    #include "listwidget.h"

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

    this->setDragDropMode( QAbstractItemView::InternalMove );
    
    connect( this->model(),
             SIGNAL(rowsMoved(QModelIndex,int,int,QModelIndex,int)),
             this,
             SLOT(rowsMoved(QModelIndex,int,int,QModelIndex,int)));
    

    }

    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?

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

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

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0
      • D Offline
        D Offline
        david.luggen
        wrote on last edited by
        #3

        Hey, I'm using Qt 5.2.1.

        1 Reply Last reply
        0
        • SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on last edited by
          #4

          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":http://bureports.qt-project.org to see if it's something known. If not please open a new report providing a minimal compilable example that shows the behavior

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          1 Reply Last reply
          0
          • D Offline
            D Offline
            david.luggen
            wrote on last edited by
            #5

            Tried it with 5.3, still the same. Search for a while at the "bug report system":bugreports.qt-project.org but didn't find anything related to this. Therefore I openend a new "report":https://bugreports.qt-project.org/browse/QTBUG-39651.

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

            1 Reply Last reply
            0
            • SGaistS Offline
              SGaistS Offline
              SGaist
              Lifetime Qt Champion
              wrote on last edited by
              #6

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

              Interested in AI ? www.idiap.ch
              Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

              1 Reply Last reply
              0

              • Login

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • Users
              • Groups
              • Search
              • Get Qt Extensions
              • Unsolved