Results 1 to 2 of 2

Thread: Tableview with grabGesture but it's slider should work with non-grabGesture logic

  1. #1
    Join Date
    Feb 2021
    Posts
    1
    Qt products
    Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Question Tableview with grabGesture but it's slider should work with non-grabGesture logic

    My goal is to have a Tableview that has 2 specific things:

    Thing #1:

    1.1 Left mouse button UP behaviour:
    When I press with the left mouse button and hold it on the view with rows and columns and move the mouse UP
    => I want to see the "QScroller::grabGesture" behaviour, it means that - the table moves down,
    and the slider on the scrollbar also moves down, while the mouse coursor with the pressed left button moves UP.

    1.2 Left mouse button DOWN behaviour:
    When I press with the left mouse button and hold it on the view with rows and columns and move the mouse DOWN
    => I want to see the "QScroller::grabGesture" behaviour, it means that - the table moves up,
    and the slider on the scrollbar also moves up, while the mouse coursor with the pressed left button moves DOWN.

    Thing #2:

    When I press with the left mouse button and hold it on the SLIDER and move the mouse up or down
    => I want to turn the "QScroller::grabGesture" behaviour OFF, and use the slider in his "default" mode, - if I move the slider down then the table moves down and if I move the slider up then the table moves up.

    ------------------------
    In my sample project QtWgtScrollerTestApp I achieve that. But I came across some problems:

    #1 Problem:
    I need to wait some time (around 200 or 400 milliseconds) after I press on the Slider for the signal QScrollBar::sliderPressed to be emited.
    If I start to move the mouse at the same time when I press on the slider, sliderMoved signal emits earlier and sliderPressed seems not to be emited at all after that.

    #2 Problem:
    When I start my app, and right away CLICK (press and release) with the left mouse button on the slider I am getting a "Segmentation fault" somewhere in a qmap source code

    Qt Code:
    1. const QMapNodeBase *QMapNodeBase::nextNode() const
    2. {
    3. const QMapNodeBase *n = this;
    4. if (n->right) {
    5. n = n->right;
    6. while (n->left) // <- "Segmentation fault" line
    7. n = n->left;
    8. } else {
    To copy to clipboard, switch view to plain text mode 


    QUESTION:
    What is the correct way to achieve the behavior for a tableview and the slider that I want and have discribed above (with Thing #1 + Thing #2) ?
    If my sample project is generally correct, how do I get ridd of the 2 problems described above ?
    Or at least how to avoid the "Segmentation fault" problem in my project ?
    Attached Files Attached Files
    Last edited by omnio2006; 4th February 2021 at 15:27.

  2. #2
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    4,836
    Thanks
    269
    Thanked 785 Times in 775 Posts
    Qt products
    Qt5
    Platforms
    Windows Android

    Default Re: Tableview with grabGesture but it's slider should work with non-grabGesture logic

    #1 Problem:
    I need to wait some time (around 200 or 400 milliseconds) after I press on the Slider for the signal QScrollBar::sliderPressed to be emited.
    This is probably something built into Qt so it can distinguish between a press and a move. There is probably a timer started when the mouse button goes down, and if a mouse move is detected before the timer fires, then the sliderMoved signal is sent. If there is no movement and the timer fires, then the pressed signal is sent.

    To achieve what you want, you will probably have to derive from QScrollBar and re-implement the mousePressEvent() and mouseMoveEvent() methods. You can set a new scrollbar on your table view via QAbstractScrollArea::setVerticalScrollBar().

    #2 Problem:
    When I start my app, and right away CLICK (press and release) with the left mouse button on the slider I am getting a "Segmentation fault" somewhere in a qmap source code
    Probably that has nothing to do with the real error - it just happens to show up there because memory got corrupted before it got to that point and that's where pointers go off into limbo.

    My guess is that you probably have a pointer variable somewhere that you are using before it is initialized, or your code has walked off the end of an array either in reading or writing.
    <=== The Great Pumpkin says ===>
    Please use CODE tags when posting source code so it is more readable. Click "Go Advanced" and then the "#" icon to insert the tags. Paste your code between them.

Similar Threads

  1. Replies: 4
    Last Post: 22nd September 2010, 23:34
  2. Replies: 5
    Last Post: 21st September 2010, 20:16
  3. Replies: 2
    Last Post: 4th September 2010, 07:18
  4. Replies: 2
    Last Post: 21st March 2010, 10:01
  5. need help in getting a logic to work
    By eva2002 in forum General Programming
    Replies: 3
    Last Post: 29th January 2010, 09:30

Tags for this Thread

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.