Search code examples
qtqscrollarea

How can i control qscrollarea horizontally


I have a QScrollArea and I want to use scroll function only horizontally. Scrollbar policy is 'AlwaysOff' because I want to hide scrollbar.

I hope to get help.


Solution

  • As I understand, you want to the widget to be able to scroll horizontally only, vertically it should be fixed.
    For that use

    void    setSizePolicy ( QSizePolicy )
    

    or

    void    setSizePolicy ( QSizePolicy::Policy horizontal, QSizePolicy::Policy vertical )
    

    where you can specify the vertical policy to be fixed and horizontal policy as required by you.

    Hope this helps. Please leave a comment if you intended something different and/or above solution does not solve your problem.