PDA

View Full Version : QListWidget update location



tvj4218
17th August 2017, 15:52
Hello.

I've got a QListWidget that I pop up on my QWidget. When I scroll the widget, the list widget does not scroll with it.
It just stays on the screen in the same place where it was originally displayed.
This list widget is not part of the container widget's layout, which is what is causing this.
I cannot have it as part of the container widget's layout as it needs to be shown/hidden
when the user clicks on a button.

Any ideas on how I could move the list widget when the container widget scrolls?

Thanks for any help.

n

Added after 8 minutes:

I suppose I could re-implement paintEvent().

high_flyer
17th August 2017, 17:18
This list widget is not part of the container widget's layout, which is what is causing this.

Not quite.
What is causing it that your list is not a *child* of the container.
If you parent it to the container it will scroll with the container.
However, note, that if you parent it to the container, it will probably popup at the upper left corner of your container (0,0).
If you want to place it where you cursor is when you right click, you will have to position it at the cursor position.
Do you know how to extract the cursor position?

tvj4218
17th August 2017, 18:23
Thanks for your reply.

Yes, I already do the positioning using setGeometry.

Turns out the list widget IS parented to the parent widget.
When I reimplement paintEVent and update the geometry, it does scroll with the widget.

But now there are two other issues.
1. The list widget is empty/blank.
2. When I scroll back up, the list widget is closed.

Thanks.

n

high_flyer
18th August 2017, 10:14
But now there are two other issues.
1. The list widget is empty/blank.
2. When I scroll back up, the list widget is closed.

And...?
I don't think there are any thelepaths on this forum.
Some explanations, code etc would be needed.