Results 1 to 10 of 10

Thread: QTreeWidget & QListWidget different selection

  1. #1
    Join Date
    Jan 2006
    Posts
    667
    Thanks
    10
    Thanked 80 Times in 74 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default QTreeWidget & QListWidget different selection

    Hi,

    When an Item is selected in QTreeWidget, the selection background extends till the width of the widget (single column QTreeWidget), whereas when an item is selected in QListWidget, the width of the selection background is relative to the width of the current Item.

    Can I make QListWidget selection behave like QTreeWidget ?

    Thanks a lot.

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,364
    Thanks
    3
    Thanked 5,013 Times in 4,791 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: QTreeWidget & QListWidget different selection

    Make sure "movement" property is set to Static.

  3. #3
    Join Date
    Jan 2006
    Posts
    667
    Thanks
    10
    Thanked 80 Times in 74 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QTreeWidget & QListWidget different selection

    Setting the property did not make any difference. Please look at the images below for the difference in the selection. I want the selection in QListWidget look like selection in the QTreeWidget.

    Please Help
    Thakns a lot.



  4. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 975 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QTreeWidget & QListWidget different selection

    Please, post images as attachments.

  5. #5
    Join Date
    Jan 2006
    Posts
    667
    Thanks
    10
    Thanked 80 Times in 74 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QTreeWidget & QListWidget different selection

    I tried attachments but for some reason the images did not show and therefore I used the other way.

  6. #6
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 975 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QTreeWidget & QListWidget different selection

    Quote Originally Posted by munna
    I tried attachments but for some reason the images did not show and therefore I used the other way.
    It worked for me:
    Attached Images Attached Images

  7. #7
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,518 Times in 1,388 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: QTreeWidget & QListWidget different selection

    What if you force the gridSize to be as wide as the width of the widget?
    http://qtnode.net/pastebin/799
    J-P Nurmi

  8. #8
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,364
    Thanks
    3
    Thanked 5,013 Times in 4,791 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: QTreeWidget & QListWidget different selection

    If I take a default, not changed in any way QListWidget, the selection is as you want it. You must have changed some property and my guess was it was the movement property because it does give an effect you described.

  9. #9
    Join Date
    Jan 2006
    Location
    Mountain View, CA
    Posts
    279
    Thanked 42 Times in 37 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QTreeWidget & QListWidget different selection

    This seems to be a problem with the Windows and Motif styles of the version of Qt I am using (Qt 4.2 tp1). The MacOs and plastique styles display OK. Can you verify which platform you are running on?

    Also, try running your app with 'app -style plastique' and see if the problem goes away.

    If so, it may be worth reporting to Trolltech.
    Last edited by Chicken Blood Machine; 20th July 2006 at 18:21.
    Save yourself some pain. Learn C++ before learning Qt.

  10. #10
    Join Date
    Jan 2006
    Posts
    667
    Thanks
    10
    Thanked 80 Times in 74 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QTreeWidget & QListWidget different selection

    I am on win xp + Qt 4.1.3. I see that it works fine with Qt3 and all other styles.

    I have not tired but will the method explain by jpn work?

Similar Threads

  1. [SOLVED] QTreeView drawing selection with icons
    By Timewarp in forum Qt Programming
    Replies: 7
    Last Post: 7th February 2013, 08:52
  2. QListWidget selection behavior
    By Arthur in forum Qt Programming
    Replies: 1
    Last Post: 30th May 2006, 15:10
  3. keypress while editing an item in QListWidget
    By Beluvius in forum Qt Programming
    Replies: 3
    Last Post: 4th April 2006, 10:56
  4. few questions related to QTreeWidget
    By prakash in forum Qt Programming
    Replies: 9
    Last Post: 10th March 2006, 08:32
  5. QListWidget add QListWidgetItem
    By fellobo in forum Qt Programming
    Replies: 3
    Last Post: 20th February 2006, 20:37

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.