Unsolved QListView vertical scroll bar not showing up.
-
Hey,
I am a Qt beginner. I need help with the QListView vertical scrollbar.The issue is that there is a QListView that has a list of items. Below that there is a hack to draw something directly into the viewport (An image is drawn). The whole list has no knowledge about it at all.
In this scenario, the vertical scrollbar (set as ScrollAsNeeded) is not showing up.
Could someone help me with what can I add so that when we shrink the app, a vertical scroll bar shows up instead of the image getting cut off. -
You draw something directly in the viewport of QListView ? Then you should also override the size() and sizeHint() functions so the ScrollArea knows the correct size.
-
Thank you Christian for your response.
I have already overridden sizeHint & minimumSizeHint methods. I tried setting viewportSizeHint but it also didn't work.
Also, on debugging, the viewport size hint shows (-1,-1). I am not sure what could the issue here?
-
Ok, from a quick look the sizeHint will not help. You have to adjust the size of the viewport() but I doubt it will really work.
-
Yeah, it didn't work.
So is it that there is no direct way to solve this?
So as a Qt beginner, is it that drawing directly to the QListview viewport is not a proper way of placing an image?
Is there a better way to deal with this issue? -
Don't paint in the viewport but in a widget below
-
Thanks, Christian. I really appreciate your help here.
Just to confirm if I understood correctly,
To add a new widget below the QListView and paint on that newly added widget instead of viewport? -
Yes. Painting inside a table/list (and outside a cell) is something I've never seen before.