Details
-
Bug
-
Resolution: Won't Do
-
P2: Important
-
None
-
5.0.1, 5.11.2, 5.12.1
-
Windows 7 64bit
Ubuntu 12.04 64-bit
Description
Steps to reproduce:
1) Create QTreeView with these properties: dragDropMode:DragDrop, defaultDropAction:MoveAction, selecetionBehavior:SelectRows
2) Populate it with QStandardItemModel composed of 2 rows and 2 columns (Enter simple text for item's DisplayRole)
3) Hide 2nd column
4) DragMove one row to another position
5) Unhide 2nd column
#include <QtWidgets> class Test : public QMainWindow { Q_OBJECT public: Test() { QWidget *central = new QWidget(); mTreeView = new QTreeView(); mTreeView->setDragDropMode(QTreeView::DragDrop); mTreeView->setDefaultDropAction(Qt::MoveAction); mTreeView->setSelectionBehavior(QTreeView::SelectRows); QGridLayout *gridLayout = new QGridLayout(central); QStandardItemModel *model = new QStandardItemModel(2, 2); for (int row = 0; row < 2; ++row) { for (int column = 0; column < 2; ++column) { QStandardItem *item = new QStandardItem(QString("r %0, c %1").arg(row).arg(column)); model->setItem(row, column, item); } } mTreeView->setModel(model); mHideColumn = new QPushButton("Hide"); mShowColumn = new QPushButton("Show"); connect(mHideColumn, SIGNAL(clicked()), this, SLOT(hideColumn())); connect(mShowColumn, SIGNAL(clicked()), this, SLOT(showColumn())); gridLayout->addWidget(mTreeView); gridLayout->addWidget(mHideColumn); gridLayout->addWidget(mShowColumn); setCentralWidget(central); } ~Test() { delete mTreeView->model(); } public slots: void hideColumn() { mTreeView->hideColumn(1); } void showColumn() { mTreeView->showColumn(1); mTreeView->resizeColumnToContents(0); mTreeView->resizeColumnToContents(1); } private: QTreeView *mTreeView; QPushButton *mHideColumn; QPushButton *mShowColumn; }; int main (int argc, char *argv[]) { QApplication a(argc, argv); Test test; test.resize(400, 400); test.show(); return a.exec(); } #include "main.moc"
Result: The DisplayRole value of the moved item (2nd column) is completely lost. Not only for the DisplayRole but any other role. If the 2nd column is not hidden it works fine.
Attachments
For Gerrit Dashboard: QTBUG-30242 | ||||||
---|---|---|---|---|---|---|
# | Subject | Branch | Project | Status | CR | V |
54581,3 | Item views DND: include hidden indexes | stable | qt/qtbase | Status: ABANDONED | -1 | 0 |
54609,2 | Item views DND: include hidden indexes | dev | qt/qtbase | Status: ABANDONED | -1 | 0 |