Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to create filters for QTableView in PyQt

Tags:

People also ask

How do you filter a value from a list in Python?

syntax: filter(function, sequence) Parameters: function: function that tests if each element of a sequence true or not. sequence: sequence which needs to be filtered, it can be sets, lists, tuples, or containers of any iterators. Returns: returns an iterator that is already filtered.

How do you filter a list?

On the Data tab of the Ribbon, in the Sort & Filter group, click Advanced, to open the Advanced Filter dialog box. For Action, select Filter the list, in-place. For List range, select the data table. For Criteria range, select C1:C2 – the criteria heading and formula cells.

How do you filter a string in Python?

filter() method is a very useful method of Python. One or more data values can be filtered from any string or list or dictionary in Python by using filter() method. It filters data based on any particular condition. It stores data when the condition returns true and discard data when returns false.


I am using QTableView to display data retrieved from QtSql.QSqlQuery

I want to know how can i create filters for it like in excel.

enter image description here

In the above image i need to get the filters for All heders (Sh_Code,SH_Seq,Stage) The filters will have unique values in of that column on which we can filter.

Required result

I need the Table view header with a dropbox listing all unique values in that column just like in excel below. No need of Top,Standard filter... as shown in image. Need only "All" and the unique "column items"

enter image description here

This is from my .NET application, uploaded for more clarity

enter image description here