Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. QTreeWidget - changing the current view when adding/removing items
Forum Updated to NodeBB v4.3 + New Features

QTreeWidget - changing the current view when adding/removing items

Scheduled Pinned Locked Moved General and Desktop
2 Posts 2 Posters 1.6k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • R Offline
    R Offline
    rooney
    wrote on last edited by
    #1

    Hi!

    I want to implement an application that is listing active chat users. I tried to use QTreeWidget to display the available users.

    The list itself will be updated every 2 seconds, so users that left the chat will be removed from the list and users that joined that chat will be added.

    But there are some problems and I would appreciate to get some advice if anyone has an idea.

    Whenever I add a user to the list, the viewport changes, so that it is recognized by the user running the application. I already tried to use scrollToItem(item, QAbstractItemView::PositionAtCenter) but that is not what I want to have. If I scroll through the list the current view should stay the same, if a new user is removed or added. Of course, if the removed/added user belongs to the current view it will change the current view. But this behaviour should not occur, if the view is somewhere in the middle of my list and the user is added at the end of the list.
    Currently, if a user is added, QTreeWidget jumps to the first item of the list.

    Regards,
    Rooney

    1 Reply Last reply
    0
    • G Offline
      G Offline
      giesbert
      wrote on last edited by
      #2

      Hi,

      without seeing what you exactly do ( by showing some coe) it is hard to say.
      In general, if you have a model and a view and you insert an item, AFAIK this works.

      Nokia Certified Qt Specialist.
      Programming Is Like Sex: One mistake and you have to support it for the rest of your life. (Michael Sinz)

      1 Reply Last reply
      0

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved