PDA

View Full Version : "Locking" a QTreeWidget ?



vkincaid
22nd December 2009, 22:16
Maybe I'm missing something from the documentation but I couldn't find a way to "lock" a QTreeWidget object, meaning no column resizing and no column drag/drop. I tried to overwrite drag*Event and dropEvent with empty bodies but that didn't do it. Would anyone know how to accomplish this?

Thanks a lot!

jpujolf
23rd December 2009, 10:06
Maybe I'm missing something from the documentation but I couldn't find a way to "lock" a QTreeWidget object, meaning no column resizing and no column drag/drop. I tried to overwrite drag*Event and dropEvent with empty bodies but that didn't do it. Would anyone know how to accomplish this?

Thanks a lot!

Take a look at QTreeWidget's base classes (http://doc.qt.nokia.com/4.6/qtreewidget-members.html) (QTreeView & QAbstractItemView ). You can use this code to "lock" column widths :



QTreeWidget * MyTree;
MyTree->header()->setResizeMode ( QHeaderView::Fixed );


And this one to lock drag & drop :


MyTree->setDragDropMode ( QAbstractItemView::NoDragDrop );

wysota
23rd December 2009, 12:34
I think the author also wants QHeaderView::setMovable(false).

jpujolf
23rd December 2009, 12:51
I think the author also wants QHeaderView::setMovable(false).

Yes, I forgot that one... :)