How to create filters for QTableView in PyQt

后端 未结 3 1077
悲哀的现实
悲哀的现实 2020-12-23 15:27

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.

3条回答
  •  北海茫月
    2020-12-23 15:58

    As per the answer from @user1006989 & @Behzad Jamali: The menu position for filtering on header won't popup at the exact position if the table has more columns than the current view port.

    To have a correct positioning of the popup menu, use this line

    posX = headerPos.x() + self.horizontalHeader.sectionViewportPosition(index)
    

提交回复
热议问题