How to lock combobox scrolling while scrolling in scrollarea?



  • Hello,

    I have a Gui with a scrollarea and scrollbar...this scrollarea has a child as groupbox in this groupbox are several groupboxes with comboboxes. Here is a little example: http://i.imgur.com/pC48cY2.png

    Now my problem is, when I am scrolling down in scrollarea and my mouse hits a combobox, while scrolling, the focus get on it and suddenly I am scrolling in the combobox. But I don't want it. How can I lock the combobox, so i can't scroll in it? Hope somebody can help me.



  • Interesting question.

    I guess you would not want to disable responding to wheel events completely for QComboBoxes. Perhaps you make an event filter for this. The filter would be activated by wheeel events send to the scroll view. You can keep the filter active for a certain time span, and not accept any scroll wheel events for any child widgets of the scroll view. Instead, you'd re-post the wheel event with the scroll view as the target.


  • Moderators

    i also suggest not to remove this feature, since it will impact the expected user experience.

    But if you really have to:
    The issue is caused because comboboxes have Qt::WheelFocus set (for QWidget's focusPolicy property). You can change it to Qt::StrongFocus to get rid of this behavior.



  • Mhm its not working with:
    @combo->setFocusPolicy( Qt::StrongFocus );@

    The Combobox still gets focus....


  • Moderators

    hardly believable.
    If that's really the case then there must be something else which sets the focus in your code.
    You should set a breakpoint for the focus-in event and check from where it comes. You can post the stack trace here then if you like.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.