Results 1 to 4 of 4

Thread: QListWidget update location

  1. #1
    Join Date
    Dec 2016
    Posts
    37
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: QListWidget update location

    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().
    Last edited by tvj4218; 17th August 2017 at 15:52.

  2. #2
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,714
    Thanks
    21
    Thanked 418 Times in 411 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: QListWidget update location

    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?
    ==========================signature=============== ==================
    S.O.L.I.D principles (use them!):
    https://en.wikipedia.org/wiki/SOLID_...iented_design)

    Do you write clean code? - if you are TDD'ing then maybe, if not, your not writing clean code.

  3. #3
    Join Date
    Dec 2016
    Posts
    37
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: QListWidget update location

    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

  4. #4
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,714
    Thanks
    21
    Thanked 418 Times in 411 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: QListWidget update location

    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.
    ==========================signature=============== ==================
    S.O.L.I.D principles (use them!):
    https://en.wikipedia.org/wiki/SOLID_...iented_design)

    Do you write clean code? - if you are TDD'ing then maybe, if not, your not writing clean code.

Similar Threads

  1. how to change a Qlistwidget's location?
    By tonylin0826 in forum Newbie
    Replies: 1
    Last Post: 22nd August 2013, 17:05
  2. Replies: 2
    Last Post: 29th September 2010, 17:44
  3. Replies: 2
    Last Post: 16th July 2010, 19:14
  4. qListWidget nad update problem
    By Talei in forum Newbie
    Replies: 4
    Last Post: 2nd April 2010, 10:05
  5. QListWidget update
    By Elwe in forum Qt Programming
    Replies: 1
    Last Post: 18th June 2009, 09:18

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.