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

TextField not editable after opening and canceling FileDialog



  • Hi!

    Newbie here! - I am confused by the following behaviours:

    I have set up a TextField and a button, which calls a fileDialog's open() method. When I cancel the fileDialog and go back to my TextField, I cannot edit it anymore (no deletion, no insertion of text possible). Why is that?

    Also, since I am on the topic: How can I pass text from the TextField to the fileDialog's save field, so that the field that determines the NAME of the file is already prefilled? (Currently "TextField.text" saves the text to the file, but instead I want the text to be the name of the file.)

    ColumnLayout {
            [...]
    	TextField {
    	        id: staffListTitle
    		width: 300
    		height: 28
    	}
            Button {
            	id: btnCreateStaffList
            	text: qsTr("Create Staff List")
            	onClicked: {
            		console.log("Clicked btnCreateStaffList")
            		createNewStaffList()
            	}
                    [...]
             }
    }
    
    function createNewStaffList() {
      [...]
      console.log("staffListTitle.text ", staffListTitle.text)
      saveFileDialog.open()
    }
    
    FileDialog {
      id: saveFileDialog
      folder: shortcuts.home
      selectExisting: false
      nameFilters: ["Text files (*.txt)", "All files (*)"]
      onAccepted: {
        //saveFile(saveFileDialog.fileUrl, staffListTitle.text)
      }
    }
    

Log in to reply