Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. [SOLVED] How to make a Vertical scrollbar inactive when Horizontal Scrollbar is in used and vice versa?
QtWS25 Last Chance

[SOLVED] How to make a Vertical scrollbar inactive when Horizontal Scrollbar is in used and vice versa?

Scheduled Pinned Locked Moved QML and Qt Quick
2 Posts 1 Posters 2.1k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • H Offline
    H Offline
    honeyhong
    wrote on last edited by
    #1

    I have these vertical and horizontal scrollbars and i want when one of the scrollbars is in used, another become inactive so that i can have smooth scrolling. is it possible with these codes?

    @

    import QtQuick 1.1
    import com.nokia.symbian 1.1
    import QtWebKit 1.0
    import "../delegates"
    import "../js/Util.js" as Util

        Page {
            id: tab1
            orientationLock: PageOrientation.LockPortrait
    
            Flickable {
                id: flicker1
                width: parent.width
                height:parent.height
                anchors{left:parent.left; leftMargin:5; right:parent.right; rightMargin:5}
                flickableDirection:Flickable.HorizontalAndVerticalFlick
                contentWidth: web.width * web.scale;
                contentHeight: web.height * web.scale;
                clip: true
    
                WebView {
                    id:web
                    html:itemNews
                    transformOrigin: WebView.TopLeft
                    preferredWidth: window.width - 10
                    preferredHeight:window.height
                    scale: window.height > 640 ? 1 : 0.8
                   }
            }
    
            ScrollBar {
                id:vertical
                flickableItem: flicker1
                anchors.right:parent.right
                anchors.top:flicker1.top
            }
    
            ScrollBar {
                    id:horizontal
                    flickableItem: flicker1
                    orientation: Qt.Horizontal
                    width:web.width * web.scale
                    anchors{left:parent.left; leftMargin:5; right:parent.right; rightMargin:10;
                        bottom:parent.bottom; bottomMargin:5}
                }
    

    }
    @

    1 Reply Last reply
    0
    • H Offline
      H Offline
      honeyhong
      wrote on last edited by
      #2

      Got it figured out myself. All I have to do is set the condition like this :

      @ flickableDirection:Flickable.Horizontal || Flickable.VerticalFlick @

      instead of
      @ flickableDirection:Flickable.HorizontalAndVerticalFlick @

      So, either horizontal or vertical scrollbar will work when scroll.
      The flickable item can now be scrolled in a more organized manner rather than moving around.

      :)

      1 Reply Last reply
      0

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved