├── Explorer ├── Explorer.qml └── qmldir ├── LICENSE ├── README.md ├── example.qml ├── qml-explorer.pri ├── qml-explorer.qrc └── qpm.json /Explorer/Explorer.qml: -------------------------------------------------------------------------------- 1 | import QtQuick 2.5 2 | import QtQuick.Controls 1.5 3 | import QtQuick.Layouts 1.2 4 | import QtQuick.Window 2.2 5 | 6 | Window { 7 | id: root 8 | title: qsTr("QML Explorer") 9 | width: 640 10 | height: 480 11 | x: 0 12 | y: Screen.desktopAvailableHeight - height 13 | visible: true 14 | flags: Qt.WindowStaysOnTopHint 15 | 16 | ColumnLayout { 17 | anchors.fill: parent 18 | anchors.margins: 9 19 | RowLayout { 20 | Layout.fillWidth: true 21 | TextField { 22 | id: input 23 | Layout.fillWidth: true 24 | focus: true 25 | onAccepted: { 26 | root.jsCall(input.text) 27 | //input.text = '' 28 | } 29 | } 30 | Button { 31 | text: qsTr("Send") 32 | onClicked: { 33 | root.jsCall(input.text) 34 | //input.text = '' 35 | } 36 | } 37 | } 38 | Item { 39 | Layout.fillWidth: true 40 | Layout.fillHeight: true 41 | Rectangle { 42 | anchors.fill: parent 43 | color: '#333' 44 | border.color: Qt.darker(color) 45 | opacity: 0.2 46 | radius: 2 47 | } 48 | 49 | ScrollView { 50 | id: scrollView 51 | anchors.fill: parent 52 | anchors.margins: 9 53 | ListView { 54 | id: resultView 55 | model: ListModel { 56 | id: outputModel 57 | } 58 | delegate: ColumnLayout { 59 | width: ListView.view.width 60 | Label { 61 | Layout.fillWidth: true 62 | color: 'green' 63 | text: "> " + model.expression 64 | } 65 | Label { 66 | Layout.fillWidth: true 67 | color: 'blue' 68 | text: "" + model.result 69 | } 70 | Rectangle { 71 | height: 1 72 | Layout.fillWidth: true 73 | color: '#333' 74 | opacity: 0.2 75 | } 76 | } 77 | } 78 | } 79 | } 80 | } 81 | 82 | function jsCall(exp) { 83 | var output = eval(exp); 84 | if (output === ''){ 85 | output = "''" 86 | } 87 | 88 | if (output !== undefined){ 89 | output = output.toString(); 90 | } 91 | 92 | var data = { 93 | expression: exp, 94 | result: output 95 | } 96 | outputModel.insert(0, data) 97 | } 98 | } 99 | -------------------------------------------------------------------------------- /Explorer/qmldir: -------------------------------------------------------------------------------- 1 | module Explorer 2 | Explorer 1.0 Explorer.qml 3 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2012-2016, Juergen Bocklage Ryannel and Johan Thelin 2 | Copyright (c) 2017-2018, Cody Scott 3 | All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are met: 7 | 8 | 1. Redistributions of source code must retain the above copyright notice, this 9 | list of conditions and the following disclaimer. 10 | 11 | 2. Redistributions in binary form must reproduce the above copyright notice, 12 | this list of conditions and the following disclaimer in the documentation 13 | and/or other materials provided with the distribution. 14 | 15 | 3. Neither the name of the copyright holder nor the names of its contributors 16 | may be used to endorse or promote products derived from this software 17 | without specific prior written permission. 18 | 19 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 20 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 21 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 22 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 23 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 24 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 25 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 26 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 27 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # QML Explorer 2 | 3 | QML Explorer is a debug window that allows you to check values in QML. 4 | 5 | The code started with the JS Console [code](https://github.com/qmlbook/qmlbook/tree/6b74cf0532d9a781f20bb34416b7c0afa8f505d9/en/ch14/src/JSConsole) 6 | in the [Cadaques book](http://qmlbook.github.io/). 7 | 8 | ## Usage 9 | 10 | 11 | Add `Explorer {}` to your .qml file. It opens a new window. 12 | 13 | 14 | ``` 15 | import QtQuick 2.5 16 | 17 | Item { 18 | id: root 19 | property string hello: "Hello" 20 | property var world: "World" 21 | Text { 22 | id: txt 23 | text: "Hello" 24 | } 25 | Explorer {} 26 | } 27 | ``` 28 | 29 | ## Example 30 | 31 | ```shell 32 | qmlscene example.qml 33 | ``` -------------------------------------------------------------------------------- /example.qml: -------------------------------------------------------------------------------- 1 | import QtQuick 2.5 2 | 3 | Item { 4 | id: root 5 | property string hello: "Hello" 6 | property var world: "World" 7 | Text { 8 | id: txt 9 | text: "Hello" 10 | } 11 | Explorer {} 12 | } 13 | -------------------------------------------------------------------------------- /qml-explorer.pri: -------------------------------------------------------------------------------- 1 | 2 | RESOURCES += \ 3 | $$PWD/qml-explorer.qrc 4 | 5 | QML_IMPORT_PATH += $$PWD 6 | -------------------------------------------------------------------------------- /qml-explorer.qrc: -------------------------------------------------------------------------------- 1 | 2 | 3 | Explorer/Explorer.qml 4 | Explorer/qmldir 5 | 6 | 7 | -------------------------------------------------------------------------------- /qpm.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "io.qpm.qml-explorer", 3 | "description": "A Debug Console to Explore QML", 4 | "author": { 5 | "name": "Cody Scott", 6 | "email": "cody.j.b.scott@gmail.com" 7 | }, 8 | "repository": { 9 | "type": "GITHUB", 10 | "url": "https://github.com/Siecje/qml-explorer.git" 11 | }, 12 | "version": { 13 | "label": "0.0.3", 14 | "revision": "", 15 | "fingerprint": "" 16 | }, 17 | "dependencies": [ 18 | ], 19 | "license": "BSD_3_CLAUSE", 20 | "pri_filename": "qml-explorer.pri", 21 | "webpage": "https://github.com/Siecje/qml-explorer" 22 | } 23 | --------------------------------------------------------------------------------