PDA

View Full Version : QHeaderView with QMenu



baray98
11th June 2010, 06:59
I have QTableView who's model is a QSqlTableModel. My goal is to have a sort and filter option to the user. As a GUI to this I would like to make QHeaderView to have buttons in them so i can assign some QMenu to that button. See attachment

I can implement the sorting and filtering part by manipulating the SQL statements. I just need to put a MS Excel touch to it.

How can I add button to QHeaderView?

baray98

wysota
11th June 2010, 17:07
Adding real buttons is a tricky thing to do because you have to synchronize them all the time. It is easier to use QStyle API to draw an artificial button on each section of the header and reimplement mouse events to provide support for activating the "buttons".