Qt World Summit: Submit your Presentation

How to add a simple directory

  • In the basic virtualKeyboard example there is a directory called content. How would I add a directory like that to my own basic Qt project?

  • Lifetime Qt Champion


    What would be in that directory ?
    How would you be using it ?

  • @SGaist In a similar manner to how its used in the keyboard example. I will be importing it into a qml script s/t I can access the qml scripts and their methods. Essentially, I have figured out how I want my keyboard to work:

        id: window
        visible: true
        width: 640
        height: 480
        title: qsTr("Hello World")
            anchors.centerIn: parent
            height: 55
            width: 120
            text: "Enter text here"
            onActiveFocusChanged: if(activeFocus) inputPanelContainer.textDisplay = inputItem.text
            onDisplayTextChanged: {
                inputPanelContainer.textDisplay = text
            z: 99
            x: 0
            y: window.height
            width: window.width
            height: childrenRect.height
            property string textDisplay:""
                anchors.top: parent.top
                width: parent.width
                height: startText.height
                color: "lightgrey"
                    horizontalCenter: parent.horizontalCenter
                id: inputPanel
                z: 99
                x: 0
                anchors.top: startText.bottom
                width: inputPanelContainer.width
            states: State
                name: "visible"
                when: inputPanel.active
                    target: inputPanelContainer
                    y: window.height - (inputPanelContainer.height + startText.height)
            transitions: Transition
                from: ""
                to: "visible"
                reversible: true
                        properties: "y"
                        duration: 250
                        easing.type: Easing.InOutQuad

    now I am trying to figure out a way to break this code up s/t I can call the keyboard anywhere within my program with a simple call to TextInput.

  • Lifetime Qt Champion

    It's just a folder to store files. Take a look at the .qrc file. You'll see them listed there.

    You can use a folder with a more suitable name for your project.

  • This post is deleted!

  • @SGaist Here is my .qrc:

        <qresource prefix="/">

    I created a folder inside of my project called Testing and named it content. I added the file TextField.qml inside that directory then I added this line to the .qrc:


    however; when I try to open the TextField.qml file inside of the IDE throws up a popup window that says:

    Could not open "/home/rob/Testing/content/TextField.qml" for reading. Either the file does not exist or you do not have the permissions to open it.

    what am I doing wrong here. I don't want a simple file I want a folder. I tried adding:

    OTHER_FILES += \
        content/TextArea.qml \

    to my .pro and then compiling and it throws an issue:

    :-1: error: No rule to make target '../Testing/content/TextField.qml', needed by 'qrc_qml.cpp'.  Stop.

  • Lifetime Qt Champion

    Do you mean you have something like:



  • @SGaist It was a permissions problem, sorry to bother you.

Log in to reply