Skip to content
  • 0 Votes
    3 Posts
    888 Views
    B

    Good idea, i will try that as soon as i find some spare time.

    Though, that cannot be the final solution. I would have to copy too much code.
    So, what's the right way of doing it?

  • 0 Votes
    10 Posts
    3k Views
    ekkescornerE

    @jpnurmi cool :)
    did some first tests with QAbstractListModel filled with some Customer* (QObject)
    inserted customers, removed customers, changed properties via C++
    all correct refreshed in QML ListView

    seems I can "port" most of my data model logic / UI from BlackBerry Cascades to Qt 5.6 :)

  • 0 Votes
    4 Posts
    2k Views
    C

    I implemented the window change using a Layout. However, I'm not sure if this is the best approach.

    Here's the code:

    blocks.qml:
    import QtQuick 2.0
    import QtQuick.Controls 1.4
    import QtQuick.Layouts 1.2
    import QtQuick.Dialogs 1.2

    Item {
    ColumnLayout {
    id: mainLayout
    anchors.fill: parent
    anchors.margins: margin

    Text { //id: tophead text: mc.blockheight } ListView { id: list model: mc Layout.fillHeight: true delegate: gridComp highlight: Rectangle { color: 'grey' } focus: true Keys.onPressed: { var pageDown = currentIndex+10; var pageUp = currentIndex-10; if (event.key === Qt.Key_PageDown && event.modifiers === Qt.NoModifier) { currentIndex = pageDown >= count ? count-1 : pageDown; event.accepted = true; } if (event.key === Qt.Key_PageUp && event.modifiers === Qt.NoModifier) { currentIndex = pageUp < 0 ? 0 : pageUp; event.accepted = true; } } } } Component { id: gridComp Row { Text { text: blocknum + " " MouseArea { anchors.fill: parent onClicked: { list.currentIndex = index; /* var component = Qt.createComponent("qrc:/detail.qml") var window = component.createObject(mainWindow) window.show() mainWindow.hide() */ ld.setSource("detail.qml") } } } Text { text: time + " " } } }

    }

    detail.qml:
    import QtQuick 2.5
    import QtQuick.Controls 1.4
    import QtQuick.Layouts 1.2
    import QtQuick.Dialogs 1.2

    Item {
    id: detailWindow
    visible: true

    ColumnLayout { Text { text: "detail.qml" } Button { text: "Back" onClicked: { ld.source = "blocks.qml" } } }

    }

    main.qml:
    import QtQuick 2.5
    import QtQuick.Controls 1.4
    import QtQuick.Layouts 1.2
    import QtQuick.Dialogs 1.2

    ApplicationWindow {
    id: mainWindow
    visible: true
    width: 640
    height: 480
    title: qsTr("Block Explorer")

    Loader { id: ld anchors.fill: parent source: "blocks.qml" }

    }

    Thanks,
    Ryan