Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Mobile and Embedded
  4. Proper forms for mobile (QML)
Forum Updated to NodeBB v4.3 + New Features

Proper forms for mobile (QML)

Scheduled Pinned Locked Moved Mobile and Embedded
formmobileqml
4 Posts 2 Posters 2.0k Views 2 Watching
  • 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.
  • V Offline
    V Offline
    Vi67
    wrote on 19 Sept 2015, 09:05 last edited by
    #1

    Hello,

    I'm trying to find the best way for making proper forms which fit mobile user behaviors.
    But I have two main problems :

    • 1st : Flickable and TextField interactions don't work well together. TextField should let flickable parent scrolling before showing keyboard.
    • 2de : Know when the keyboard is displayed, then make Flickable going further than its content height. It enables to show entirely the form even with keyboard displayed.

    For the 1st problem, I found a bad hack. It's not working well because if you hide keyboard, you can't show keyboard again directly by just clicking on it.

    Input.qml

    Item {
    	TextField {
    		id: field
    		anchors.fill: parent
    	}
    
    	MouseArea {
    		anchors.fill: parent
    		preventStealing: false
    
    		onReleased: {
    			field.forceActiveFocus();
    		}
    	}
    }
    

    For the 2de problem, I didn't find a way to know if keyboard is displayed. If I could, I can add an empty Item at the end of Flickable content like this :

    ScrollView {
        anchors.fill: parent
        horizontalScrollBarPolicy: Qt.ScrollBarAlwaysOff
        verticalScrollBarPolicy: Qt.ScrollBarAsNeeded
    
        Flickable {
            anchors.fill: parent
            contentWidth: col.width; contentHeight: col.height
            boundsBehavior: Flickable.StopAtBounds
    
    		Column {
    			id: col
    			width: screen.width
    			
    			Input {} // = TextField
    			Input {} // = TextField
    			Input {} // = TextField
    			
    			// potential fix
    			Item {
    				width: parent.width
    				height: Qt.Keyboard.height
    				visible: Qt.Keyboard.visible
    			}
    		}
    	}
    }
    

    Thank you in advance for your help

    1 Reply Last reply
    0
    • B Offline
      B Offline
      benlau
      Qt Champions 2016
      wrote on 19 Sept 2015, 13:06 last edited by
      #2

      For Android, you may set to resize window when keyboard is shown. Your Flickable will resize to occupy remaining space, then you should scroll the text field to top.

      e.g

      Add this property into the Activity tag inside AndroidManifest.xml
      android:windowSoftInputMode="adjustResize"

      1 Reply Last reply
      0
      • V Offline
        V Offline
        Vi67
        wrote on 19 Sept 2015, 13:40 last edited by
        #3

        Thank you very much, it fixes the second problem perfectly.
        There is still first problem, any idea ?

        B 1 Reply Last reply 21 Sept 2015, 11:49
        0
        • V Vi67
          19 Sept 2015, 13:40

          Thank you very much, it fixes the second problem perfectly.
          There is still first problem, any idea ?

          B Offline
          B Offline
          benlau
          Qt Champions 2016
          wrote on 21 Sept 2015, 11:49 last edited by benlau
          #4

          @Vi67 hmm. Not quite understand your first problem.

          1 Reply Last reply
          0

          1/4

          19 Sept 2015, 09:05

          • Login

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