Results 1 to 3 of 3

Thread: How to capture resizing of QTreeWidget columns?

  1. #1
    Join Date
    Feb 2006
    Posts
    11
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default How to capture resizing of QTreeWidget columns?

    I would like to know if the user resizes the columns of a QTreeWidget, but I can't seem to find a way to do this.

    I have tried using the itemPressed/Clicked/etc signals in the QTreeWidget, but clicking the headerItem obviously doesn't cause these signals to be emitted.

    I have also tried to capture the mouseRelease events on both the QTreeWidget widget directly, and its viewport, but neither seem receive the Release event when clicking the header.

    Does anyone know how I could do this?

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

    Default Re: How to capture resizing of QTreeWidget columns?

    I am not sure but i think it can be done in the following way.

    In the mousePressEvent you should find which column is being pressed using columnViewportPosition(int column) and probably store the columnWidth somewhere.

    In the mouseReleaseEvent you can compare the widths and then emit a signal.

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

    Default Re: How to capture resizing of QTreeWidget columns?

    Connect to signal void QHeaderView::sectionResized(int logicalIndex, int oldSize, int newSize).
    You can obtain the header for the table widget by QTreeView::header().
    J-P Nurmi

  4. The following user says thank you to jpn for this useful post:

    simk (27th April 2006)

Similar Threads

  1. QTreeWidget, proper resizing of columns
    By soul_rebel in forum Qt Programming
    Replies: 2
    Last Post: 6th November 2007, 01:06
  2. Saving/Restoring columns order of QTreeWidget
    By mchara in forum Qt Programming
    Replies: 1
    Last Post: 10th October 2007, 08:43
  3. QTreeWidget - preventing columns from being resized.
    By sternocera in forum Qt Programming
    Replies: 1
    Last Post: 13th September 2007, 16:11
  4. QTreeWidget columns
    By xgoan in forum Newbie
    Replies: 3
    Last Post: 27th February 2007, 20:01
  5. resizing a QTreeWidget
    By drhex in forum Qt Programming
    Replies: 6
    Last Post: 27th October 2006, 22:32

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.