QTreeView with multiple Widgets in columns?
How to insert a check box , button and combobx in each column inside QTreeView?
please help me :(
setIndexWidget comes to mind, or a custom delegate. Note that if you just want to display a checkbox next to an item, you can just set the Qt::ItemIsUserCheckable flag (and manage the value for the Qt::CheckStateRole in data/setData).
You can not do it. setIndexWidget will only allow setting a single item in a cell, not multiple. However, you can of course make your own compound widget that consists of a checkbox, a button and a combobox in a layout, and set an instance of that widget in a tree view.
Note however, that using setIndexWidget is not very performant for large models.
bq. make your own compound widget that consists of a checkbox, a button and a combobox in a layout, and set an instance of that widget in a tree view
I can do that but , how to show different widget in different columns? like
QTreeView will have ,
col-1 | col2 | col3 ----
QLineEdit QCheckBox QComboBox -----
is it possible to achieve this using QStyledItemDelegate? or any other way?
please put me in right direction with some sample code.
thanks in advance.
I thought you wanted to put multiple widgets in a single cell. If you just want one item per cell, just put your widgets in your cells directly as directed earlier by peppe, and take note of his suggestion that you don't need to use a QCheckBox widget because that can be rendered by the item view (ok, the default delegate, but that is besides the point) directly.
Or, if it is enough to have the widgets for editing, I would prefer a QStyledItemDelegate subclass as item delegate in the view. That way, you only have one widget active at one point in time and only create them when the user starts editing the cells.
can you please show me with some sample code on how to get it.
You can find good examples "in the docs":http://doc.qt.nokia.com/4.7/model-view-programming.html#delegate-classes