Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

Drag from QHeaderView



  • Hi All,

    I try to drag horizontal Header of a QTableView but I have no success with :

    @ ui->tableview->horizontalHeader()->setDragEnabled(true);
    ui->tableview->horizontalHeader()->setDragDropMode(QAbstractItemView::DragOnly);@

    drop mechanism seems to be ok as I can drop all cells of the tableView itself without problem to my drop widget.

    Nothing found that way in the forum. Any idea is welcome.



  • it doesn't mean that if you can drag and drop your cells that you can drag and drop headers. Those are two separate things.

    from the QHeaderView docs :
    Moving Header Sections

    A header can be fixed in place, or made movable with setMovable()....

    it might be a good idea to use also setDropIndicatorShown(true);


Log in to reply