Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

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

    Hi,

    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:

    Window
    {
        id: window
        visible: true
        width: 640
        height: 480
        title: qsTr("Hello World")
    
        TextInput
        {
            id:inputItem
            anchors.centerIn: parent
            height: 55
            width: 120
            text: "Enter text here"
    
            onActiveFocusChanged: if(activeFocus) inputPanelContainer.textDisplay = inputItem.text
    
            onDisplayTextChanged: {
                inputPanelContainer.textDisplay = text
            }
        }
    
        Item
        {
            id:inputPanelContainer
            z: 99
            x: 0
            y: window.height
            width: window.width
            height: childrenRect.height
            property string textDisplay:""
    
            Rectangle
            {
                anchors.top: parent.top
                width: parent.width
                height: startText.height
                color: "lightgrey"
            }
    
            Text
            {
                id:startText
                text:inputPanelContainer.textDisplay
                anchors{
                    top:parent.top
                    horizontalCenter: parent.horizontalCenter
                }
            }
    
            InputPanel
            {
                id: inputPanel
                z: 99
                x: 0
                anchors.top: startText.bottom
                width: inputPanelContainer.width
            }
    
            states: State
            {
                name: "visible"
                when: inputPanel.active
    
                PropertyChanges
                {
                    target: inputPanelContainer
                    y: window.height - (inputPanelContainer.height + startText.height)
                }
            }
            transitions: Transition
            {
                from: ""
                to: "visible"
                reversible: true
    
                ParallelAnimation
                {
    
                    NumberAnimation
                    {
                        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:

    <RCC>
        <qresource prefix="/">
    	<file>content/TextField.qml</file>
            <file>main.qml</file>
        </qresource>
    </RCC>
    

    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:

    <file>content/TextField.qml</file>
    

    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:

    yourproject.pro
    somename.qrc
    Testing/content/TextArea.qml
    

    ?



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


Log in to reply