Results 1 to 3 of 3

Thread: QSplitter/SplitterMoved

  1. #1
    Join Date
    Mar 2007
    Posts
    74
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Windows

    Default QSplitter/SplitterMoved

    Hi,

    I have a QSplitter controlling a QTreeWidget on top and a
    group of 4 buttons on the bottom. I have placed the 4 buttons
    in a frame who has a fixed height and a max height which
    is only slightly larger than its min height.

    What I want to do is catch the direction of the vertical
    scroller movement and hide/show one or more of the
    buttons in the frame.

    This works to the extent that the frame corectly resizes
    when I hide/show a button.

    My problem is determining where the vertical scrollbar
    has moved.

    Catching the splitterMoved Signal only tells me the
    new position. Hiding or Showing one of the buttons
    results in a resizeEvent for the XMLtree and another
    splitterMoved Signal call with the new position.


    I need a way to differentiate between a splitterMoved Signal
    due to a resizing and one from an actual move of the splitter
    handle. It would be nice if they generated different event types
    but they don't..

    Thanks

    Mark

  2. #2
    Join Date
    Jan 2008
    Location
    Silicon valley
    Posts
    15
    Thanked 2 Times in 2 Posts
    Qt products
    Qt3 Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: QSplitter/SplitterMoved

    Quote Originally Posted by MrGarbage View Post
    My problem is determining where the vertical scrollbar
    has moved.

    Catching the splitterMoved Signal only tells me the
    new position. Hiding or Showing one of the buttons
    results in a resizeEvent for the XMLtree and another
    splitterMoved Signal call with the new position.
    So your problem seems to be not where the vertical scrollbar has moved, but how it has been moved (using mouse or programmatically).

    The easiest method seems to be to check the mouse cursor position and probably button state; if it's on the splitter and the button is down, the splitter has been moved by mouse; otherwise by program.

    More reliable method is to reimplement void mousePressEvent() and mouseReleaseEvent() in your splitter subclass to set some kind of variable regarding current mouse position, and check this variable in your splitterMoved() handler.

    If it's not what you want, could you please elaborate?

  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: QSplitter/SplitterMoved

    One idea could be to try putting those buttons inside a simple wrapper widget. This wrapper widget would simply show/hide the buttons accordingly in its resizeEvent(). This way you wouldn't have to rely on the signal at all...
    J-P Nurmi

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
  •  
Qt is a trademark of The Qt Company.