Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
QComboBox in QTableWidgetItem of Header
Kritika last edited by
I am using QTableWidget, in this i want one of the column heading as QCombobox. Other column headings are strings which is its normal functionality. Can anyone tell me how to use qwidget in one of headerItem?
poorBob last edited by
for the moment I can see two possible solutions, but I don't have time to test them.
In first solution You can try to use "QTableWidget::setHorizontalHeaderItem() method":http://qt-project.org/doc/qt-4.8/qtablewidget.html#setHorizontalHeaderItem to place there a QComboBox. You can subclass the "QTableWidhetItem":http://qt-project.org/doc/qt-4.8/qtablewidgetitem.html and maybe this will work.
-_ If above solution won't work, please note that QTableWidget's header is implemented with class "QHeaderView":http://qt-project.org/doc/qt-4.8/qheaderview.html . _-
I wanted to write that QHeaderView derives from QAbstractItemView and You can try to write custom delegate, but the I have notice in QHeaderView's documentation that: "Note: Each header renders the data for each section itself, and does not rely on a delegate. As a result, calling a header's setItemDelegate() function will have no effect."
So no item delegate would work....
Try to check this topic for the solution: "http://www.qtcentre.org/threads/27077-Quick-way-for-QWidget-in-QHeaderView-s-columns":http://www.qtcentre.org/threads/27077-Quick-way-for-QWidget-in-QHeaderView-s-columns
Hope that will help You,