Skip to content
  • 0 Votes
    3 Posts
    10k Views
    L

    @p3c0 Yes that worked. Thanks!

    Here is the full working code, if someone else wants to use the tableView with cell-navigation instead of row-navigation:

    import QtQuick 2.4 import QtQuick.Controls 1.3 import QtQuick.Layouts 1.1 Item { width: 640 height: 480 ListModel { id: tstModel ListElement { animal: "dog" age: "10" } ListElement { animal: "cat" age: "12" } ListElement { animal: "bird" age: "1" } ListElement { animal: "elephant" age: "20" } ListElement { animal: "turtle" age: "100" } } TableView { id: tableView anchors.fill: parent anchors.topMargin: 40 highlightOnFocus: false model: tstModel property int currentColumn: 0 rowDelegate: Rectangle { color: "#fff" } itemDelegate: Rectangle { // color: "transparent" color: { var bgColor = model.index%2 ? "whitesmoke" : "white" var activeRow = tableView.currentRow === styleData.row var activeColumn = tableView.currentColumn === styleData.column activeRow && activeColumn ? "steelblue" : bgColor } Text { text: styleData.value } MouseArea { anchors.fill: parent onClicked: { print("(onClick) index: (" + model.index + "," + tableView.currentColumn+ ")") tableView.currentRow = styleData.row tableView.currentColumn = styleData.column model.currentIndex = styleData.row parent.forceActiveFocus() } } Keys.onRightPressed: { console.log("Delegate Right") if (tableView.currentColumn < tableView.columnCount - 1) tableView.currentColumn++ parent.forceActiveFocus() print("(Right) index: (" + tableView.currentRow + "," + tableView.currentColumn+ ")") } Keys.onLeftPressed: { console.log("Delegate Left") if (tableView.currentColumn > 0) tableView.currentColumn-- parent.forceActiveFocus() print("(Left) index: (" + tableView.currentRow + "," + tableView.currentColumn+ ")") } } Keys.onRightPressed: { print("(Right - Table) index: (" + tableView.currentRow + "," + tableView.currentColumn+ ")") if (tableView.currentColumn < tableView.columnCount - 1) tableView.currentColumn++ } Keys.onLeftPressed: { print("(Left - Table) index: (" + tableView.currentRow + "," + tableView.currentColumn+ ")") if (tableView.currentColumn > 0) tableView.currentColumn-- } Keys.onUpPressed: { print("(Up - Table) index: (" + tableView.currentRow + "," + tableView.currentColumn+ ")") if (tableView.currentRow > 0) tableView.currentRow-- } Keys.onDownPressed: { print("(Down - Table) index: (" + tableView.currentRow + "," + tableView.currentColumn+ ")") if (tableView.currentRow < tableView.rowCount - 1) tableView.currentRow++ } TableViewColumn { id: animalColumn title: "Animal" role: "animal" movable: false resizable: false width: parent.width / 2 } TableViewColumn { id: ageColumn title: "Age" role: "age" movable: false resizable: false width: parent.width / 2 } } }
  • 0 Votes
    2 Posts
    2k Views
    L

    I've been experimenting further and reading through the source code. Again, I still only see the inputMethodQuery and inputMethodEvent functions as entry points to potentially return a QVariantMap with a "returnKeyType" property, and neither one can be overridden.

    I tried creating an inline function in my QML code for a TextEdit/TextInput, but the meta method created has a QVariant parameter instead of a Qt::InputMethodQuery, so the logic from QInputMethod does not go through this function.

    It looks like the android code completely ignores the ImPlatformData value (at least as of Qt 5.3.1 where I am based). It may be that this was only ever handled in iOS logic previously? If that is the case, then I will have to abandon this effort and wait for Qt 5.6 to come in with native support for returnKeyType. Unfortunately, that will be too late for this project release.

  • 0 Votes
    13 Posts
    4k Views
    Z

    @p3c0 it does yet I wanted to fix the problem I personally faced thanks for an advice

  • 0 Votes
    7 Posts
    7k Views
    T

    Here is the complete solution:

    import QtQuick 2.2 import QtQuick.Controls 1.2 import QtQuick.Layouts 1.1 import OskPlugin 1.0 Rectangle { id: root width: 1024 height: 633 ListModel { id: personalData ListElement { dataLabel: "Firstname"; dataValue: "Herbert"; } ListElement { dataLabel: "Lastname"; dataValue: "Roth"; } ListElement { dataLabel: "Plays"; dataValue: "Guitar"; } ListElement { dataLabel: "Age"; dataValue: "65";} ListElement { dataLabel: "Hobby"; dataValue: "Walking"; } ListElement { dataLabel: "Birthday"; dataValue: "14.12.1926"; } ListElement { dataLabel: "City";dataValue: "Suhl"; } ListElement { dataLabel: "Country"; dataValue: "Germany"; } } ScrollView { anchors.fill: parent ListView { id: listView anchors.fill: parent clip: true model: personalData focus: true delegate: FocusScope { x: rectangle.x; y: rectangle.y width: rectangle.width; height: rectangle.height Rectangle { id: rectangle height: 66 width: 500 border.color: "grey" border.width: 2 TextInput { anchors.centerIn: parent text: dataValue font.pixelSize: 24 focus: true activeFocusOnTab: true onActiveFocusChanged: if(activeFocus) { listView.currentIndex = index } } } } } } }