Hi,

I've implemented a tree model on top of a QSqlTableModel via a proxy model (QSqlTableModel doesn't work well with parent/child relationships). It works great, except when I hide the first column of the view (id column). I want to hide the id column because I don't want it in the view but once I do, dragging children does not work. Any thoughts? I haven't been able to make any progress on this. code attached and below. Thanks!

sqltreemodel.h

Qt Code:
  1. #define TREEMODEL_H
  2.  
  3. #include <QSqlTableModel>
  4.  
  5. class sqlTreeModel : public QSqlTableModel
  6. {
  7. Q_OBJECT
  8.  
  9. public:
  10. sqlTreeModel(QObject *parent=nullptr);
  11.  
  12. virtual Qt::DropActions supportedDragActions() const { return Qt::MoveAction; }
  13. virtual Qt::DropActions supportedDropActions() const { return Qt::MoveAction; }
  14. };
  15.  
  16. #endif // TREEMODEL_H
To copy to clipboard, switch view to plain text mode 


mainwindow.h
Qt Code:
  1. #ifndef MAINWINDOW_H
  2. #define MAINWINDOW_H
  3.  
  4. #include <QMainWindow>
  5. #include <QSqlError>
  6.  
  7. class QTreeView;
  8. class sqlTreeModel;
  9. class proxyTreeModel;
  10.  
  11. class MainWindow : public QMainWindow
  12. {
  13. Q_OBJECT
  14.  
  15. public:
  16. explicit MainWindow(QWidget *parent = nullptr);
  17.  
  18. private:
  19. QTreeView *treeView;
  20.  
  21. sqlTreeModel *plidModel;
  22. proxyTreeModel *proxyPlidModel;
  23. QHash<QString,QPair<int,int> > playlistVideoTracker;
  24.  
  25. QSqlError initdb();
  26. void setupModels();
  27. };
  28.  
To copy to clipboard, switch view to plain text mode