Solved Displaying Widget Below QTableView Row
-
Right now I have a simple table displaying data, but a requirement is that the user can click on a table row and a widget will be displayed below the row with a chart of supplementary information that can be interacted with.
I've used delegates before to paint cells and rows with custom styles, but I've never had a row that was expanded to show another widget. Is it possible to create a delegate that is painted like a normal row but also has an embedded widget that deals with it's own input and paint events?
My idea is to set the size hint for the selected row and have it expand, then set a delegate on it that will display the supplementary information widget.
-
Hi
If you don't override paint for you delegate the cells will draw as normal.
Then in CreatorEditor, you can create any widget you wish even complex ones.
But as soon as user click on another cell the Editor widget is deleted and you must then set row size to normal.
So im not sure how good it will work, but its worth a shot.Is there only one column, or do you want the user to click any col on a row and it
pretends its one row showing the cart along the full width?Im asking as delegates are cell orientated and will clip to cells area pr default so spanning
multiple might be more involving.How many rows will you have ?
-
Hi
If you don't override paint for you delegate the cells will draw as normal.
Then in CreatorEditor, you can create any widget you wish even complex ones.
But as soon as user click on another cell the Editor widget is deleted and you must then set row size to normal.
So im not sure how good it will work, but its worth a shot.Is there only one column, or do you want the user to click any col on a row and it
pretends its one row showing the cart along the full width?Im asking as delegates are cell orientated and will clip to cells area pr default so spanning
multiple might be more involving.How many rows will you have ?
-
@mrjj said in Displaying Widget Below QTableView Row:
Is there only one column, or do you want the user to click any col on a row and it
pretends its one row showing the cart along the full width?Im asking as delegates are cell orientated and will clip to cells area pr default so spanning
multiple might be more involving.This is the case, the user can click on any column in the row and it will display the inline widget below the selected row.
I forgot about delegates being cell oriented. I may just have to increase the size of the selected row then in the model set the text alignment to the top, then manually move the widget into the right place.
-
@Qt_User72653
I think its worth a shot
but expect some fiddling around to get the chart widget to align correctly.I assume you will have many rows since you chose table + delegate versus
ScrollArea with collapsible widgets. -
Yep, it's a table view with an arbitrary number of rows.
The table provides the rowViewportPosition() (or something like that), so getting the position right hopefully won't be too hard.
-
@Qt_User72653
Ok then View+Model +delegate is the right way :)
Getting the info should not be super hard but you might need to keep a pointer to the view.
I think your plan with setting the height of the row and then make the Editor appear sounds good.
It should work without too many odd issues :)