Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
Hiding individual cells of QTableWidget
Muster Maxmann last edited by aha_1980
I have a QDialog in which I would like to implement following idea: A text searchbox and under this searchbox I have a QTableWidget in which I put QIcons and a description text. The searchbox now should filter the QTableWidget with the help of the text in the searchbox and the description text and also hidden IDs while typing. For implementing this (it's supposed to be a texture/tile choosing dialog at the end) I would like to be able to hide individual cells of the QTableWidget, but I only seem to find ways to hide whole columns or rows. An idea now would be removing all entries in the QTableWidget on every keystroke and reinsert only those who match the search criteria, but it seems unlikely to me that this is the most efficent way Qt offers me since such a filter dialog is a fairly common task when working with UIs. Is there any way to toggle the visibility of single cells of QTableWidgets or is this just a drawback coming from the fact that QTableWidgets are based on QTableViews? What would be the best alternative for me? I search the QT documentation since a half day for a solution to this problem now, I hope someone here can help me.
Thanks in advance
Hi and welcome to devnet,
By hiding, do you mean that the elements below the cell should all move up ?
Muster Maxmann last edited by Muster Maxmann
@SGaist Yes. Exactly that would be the goal.
Example (every number is one entry consisting of a QTableWidgetItem with a QIcon and a text set with setText)
1 2 3 4
5 6 7 8
Filtered 3 and 5:
1 2 4 6
Edit: Thanks for the nice welcome :)
Then what comes to mind is possibly a proxy on top of a table model that would do the remapping knowing which index is hidden.
QTableWidget in which I put QIcons and a description text.
Muster Maxmann last edited by
Okay proxy and listView is what solved the problem for me, thanks @SGaist and @Christian-Ehrlicher. I made a QListView and filtered it with the input of a QLineEdit and a sortFilterProxy, then I toke the data of the sortFilter and inserted it into a QTableView and cleaned the presentation with a delegate up. It works fast and snappy with my 20 exmaple data, I just hope that it keeps working as good with my ~300 data, but to get to this tests I have to finish other parts of my project first. I call this solved for now :-)