[PyQt] QtableView Header. How to add top-right small button to hide/show column with checked/unchecked Checkboxes?
With PyQt4, I am using a QtableView with more than 10 columns. The user must have the choice of showing/hiding a column.
This is generally done by adding a small button in the top-right of the table's header. The button shows a menu with checked/unchecked Checkboxes allowing to hide/show columns.
This is an example of a Sqlite-Manager Table :http://williamsportwebdeveloper.com/cgi/wp/wp-content/uploads/2010/08/SQLiteManager.png.
So, I wonder how can I do the same with PyQt's QtableView?
I have not used PyQt. From Qt C++ perspective, you can get Header view for TableView and implement your own delegate to have checkboxes. Based on the actions on the delegate you can hide/show columns you want.
Another possibility is to make two components separately
- Header Component and View Component
- Show them in vertical layout. You can handle the action of header component.
A solution was proposed "here":http://stackoverflow.com/questions/25744109/pyqt-qtableview-header-how-to-add-top-right-small-button-to-hide-show-column-wi/25752676?noredirect=1#comment40275860_25752676.