Unsolved Show only rows with invalid value in QT Tree view
-
I have one tree view. I need one functionality like check box.
On clicking on check Box it should display the rows with only invalid values.
On uncheck the tree should show all the rows.
How can I achieve this. -
What are invalid value? What model are you using?
You can set the "isCheckable" flag to your item to make it checkable. -
@ayush-gupta
(Probably) Like all these "makeQTreeView
only show certain rows", interpose a https://doc.qt.io/qt-5/qsortfilterproxymodel.html between the view and your actual model to filter in/out desired rows, according to whatever your criteria are. -
@pl45m4 said in Show only rows with invalid value in QT Tree view:
isCheckable
@JonB you mean to say override filterAcceptsRow?
@Pl45m4 I am using QSortFilterProxyModel. I mean some rows with invalid value which i mark red background in my tree view.
isCheckable is not my requirement. -
@ayush-gupta said in Show only rows with invalid value in QT Tree view:
I need one functionality like check box.
You were asking for a checkBox inside your treeView. This was at least one part of your question :)
So you have your checkBox already in your view and you are asking for a solution to toggle between "all" and "invalid only" ?
-
@JonB you mean to say override filterAcceptsRow?
Yes, via https://doc.qt.io/qt-5/qsortfilterproxymodel.html#filterAcceptsRow.
-
@pl45m4
I don't think OP is looking for a checkbox against each row. He simply has some widget outside the table view rows which he uses to indicate what behaviour is wanted (exclude "invalid" rows or not) across all table rows. -
@Pl45m4 Yes I need a solution to toggle between all and invalid only.
@JonB @Pl45m4 Is right
What I want tree views contains lot of rows with data.
Also the invalid rows which are marked as red.
So on clicking check box only invalid rows should be displayed in tree view
on uncheck all rows with invalid value should display.@JonB If I use filterAcceptAllrow() which property of item helps me in filtering can you point it out?
-
@ayush-gupta
What you say does not make sense. If you have a checkbox against each individual row, how can that be for showing/hiding/filtering all rows? If you want one checkbox to affect all rows somehow, which is what you say, it should not be against each row, but outside of the rows. I leave it to you.@JonB If I use filterAcceptAllrow() which property of item helps me in filtering can you point it out?
Only you know whatever it is in each row in your model which makes you consider that row to be "invalid". It's not a property of the view or model. Presumably whatever criteria you currently use for your "Also the invalid rows which are marked as red".