Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

Independent scroll areas for separate vertical horizontal scrolling



  • Hi,

    I would like to create a user interface with a time scale (hours of the day from 00:00 to 23:59) and a variable number of columns on the right side for certain type information.

    4c449b14-314d-49bc-887d-97b288c898f4-image.png

    Here is the layout:
    9e10a812-8be7-4ac3-b8c3-46d109e2f5bb-image.png

    I separated into 2 scrollAreas (one parent with vertical scrolling for all the times and another one for horizontal scrolling for the columns).
    The reason for this layout is to make time scale always visible even though one scrolls to right. Otherwise, timeScale disappears.
    Like this:
    1a363a5a-50f3-400b-a1e1-3feb062ea362-image.png

    Now my problem is that the horizontal scroll bar disappears when I scroll up:
    6795a5b5-5de5-440c-b846-f727e705fe92-image.png

    I was wondering if there is there any way to solve this problem?

    Edit: Here are some ideas I had but couldn't implement yet:

    • Can I take the horizontal scroll bar outside of scroll area?

    • Can I create a new separate scroll bar outside of scroll area and assign it to the scroll area?


  • Lifetime Qt Champion

    Hi,

    You might want to check the frozen column example to get some ideas.

    One quick idea that comes to mind is to put the time scale in its own scroll area and sync it with the "main" one. Keep the scroll bars invisible for the time scale. And use only on area for the your "main" part.


  • Lifetime Qt Champion

    Hi,

    You might want to check the frozen column example to get some ideas.

    One quick idea that comes to mind is to put the time scale in its own scroll area and sync it with the "main" one. Keep the scroll bars invisible for the time scale. And use only on area for the your "main" part.



  • @SGaist
    I looked at the code and there was a connect() function, which got my attention. So I looked into it and found PyQt (I didn't mention this before) equivalent. So basically by adding an external scrollbar and connecting to the hidden scrollbar of the scrollArea did the trick. Thanks a lot!
    self.horizontalScrollBar.valueChanged.connect(self.scrollArea.horizontalScrollBar().setValue)
    7bb04598-61ab-4b5b-8f6c-e455c9a3b378-image.png


Log in to reply