Qt World Summit: Register Today!

ScrollView: scroll bars wrongly appear though content is smaller

  • I have a ScrollView with contents that entirely fit inside the ScrollView. For instance:

    ScrollView { x: 20; y: 20; width: 120 + 4; height: 90 + 4;
        Rectangle { x: 0; y: 0; width: 120; height: 90; color: "green" } }

    Typically, scroll bars should appear only if the content exceeds width or height of the ScrollVIew. However, here the ScrollView opens with both horizontal and vertical scroll bars visible. Even though the content is smaller than the ScrollView contents area. Only if I replace the "+ 4" with something like "+ 24" (>= width of scroll bars), so that the ScrollView gets notably bigger than its contents, the scroll bars disappear. The scroll bars also disappear if I bind the dimensions of the ScrollView to a window and resize it manually.

    Main question: is scroll bar's initial appearance in this scenario just a bug in Qt 5.3 or is there a clean way to hide them programmatically (unless content dimensions really exceed container's dimensions)?

    Note: if above's snipplet doesn't show scroll bars on your machine then this may be a platform-specific bug of Qt. I use Qt 5.3 on X11 and haven't checked other platforms yet. Please let me know if your result differs.

Log in to reply