onEditingFinished is not available due to component versioning
-
I'm new to Qt and might be missing something obvious.
I can't get a handler for onEditingFinished for a textfield in quick controls 2 to work. QtCreator thinks this is a valid signal, but at run time I get: ".onEditingFinished" is not available due to component versioning
According to the docs, that signal has been there forever. I'm running 5.7.1 (built from source).
To reproduce:
In qtcreator:
Create a new application using the quick controls 2 template
Add an onEditingFinished handler to the textfield
Run it -
I'm new to Qt and might be missing something obvious.
I can't get a handler for onEditingFinished for a textfield in quick controls 2 to work. QtCreator thinks this is a valid signal, but at run time I get: ".onEditingFinished" is not available due to component versioning
According to the docs, that signal has been there forever. I'm running 5.7.1 (built from source).
To reproduce:
In qtcreator:
Create a new application using the quick controls 2 template
Add an onEditingFinished handler to the textfield
Run it@DanCA-A Do you have
import QtQuick.Controls 1.2
in your file? It was introduced in 1.1 so you can try that as well, 1.2 may be in 5.8 only. -
QtCreator included this:
import QtQuick 2.7Would I need that and QtQuick.Controls? (newbie question)
I tried adding it, and also tried versions 1.3 and 1.4. No improvement.
@DanCA-A Yea you need to add the controls line too, it should looks like this:
import QtQuick 2.7 import QtQuick.Controls 2.1
Edit: that is for 5.8 though I think, you may need to adjust the versions for your 5.7 app.
-
It's QtQuick.Controls 2.0 for 5.7.1, but that still didn't fix it.
I ended up switch to the "accepted" signal instead of "editingFinished".
As far as I can tell the latter is either broken or mis-documented. Is there someplace I should file a bug?
Thanks for the tips, though!
-
Works for me with Qt 5.8.0:
import QtQuick 2.7 import QtQuick.Controls 2.1 ApplicationWindow { visible: true width: 640 height: 480 TextField { text: "nx" anchors.centerIn: parent onEditingFinished: console.log("Hello") } }
-
Works for me with Qt 5.8.0:
import QtQuick 2.7 import QtQuick.Controls 2.1 ApplicationWindow { visible: true width: 640 height: 480 TextField { text: "nx" anchors.centerIn: parent onEditingFinished: console.log("Hello") } }
@Wieland That does work, but it's not how qtcreator does things. Being new to Qt, I'm pretty dependent on the tools to help me get going.
It's doing layout in one file and attaching handlers in another. That isn't working.
Page1Form.ui.qml
import QtQuick 2.7 import QtQuick.Controls 2.0 import QtQuick.Layouts 1.0 Item { property alias textField1: textField1 property alias button1: button1 RowLayout { anchors.horizontalCenter: parent.horizontalCenter anchors.topMargin: 20 anchors.top: parent.top TextField { id: textField1 placeholderText: qsTr("Text Field") } Button { id: button1 text: qsTr("Press Me") } } }
Page1.qml
import QtQuick 2.7 import QtQuick.Controls 2.0 Page1Form { textField1.onAccepted: { console.log("Accepted text: " + textField1.text); } /*textField1.onEditingFinished: { console.log("Editing finished text: " + textField1.text); }*/ button1.onClicked: { console.log("Button Pressed. Entered text: " + textField1.text); } }
Uncomment the above code to see the problem.
-
@Wieland That does work, but it's not how qtcreator does things. Being new to Qt, I'm pretty dependent on the tools to help me get going.
It's doing layout in one file and attaching handlers in another. That isn't working.
Page1Form.ui.qml
import QtQuick 2.7 import QtQuick.Controls 2.0 import QtQuick.Layouts 1.0 Item { property alias textField1: textField1 property alias button1: button1 RowLayout { anchors.horizontalCenter: parent.horizontalCenter anchors.topMargin: 20 anchors.top: parent.top TextField { id: textField1 placeholderText: qsTr("Text Field") } Button { id: button1 text: qsTr("Press Me") } } }
Page1.qml
import QtQuick 2.7 import QtQuick.Controls 2.0 Page1Form { textField1.onAccepted: { console.log("Accepted text: " + textField1.text); } /*textField1.onEditingFinished: { console.log("Editing finished text: " + textField1.text); }*/ button1.onClicked: { console.log("Button Pressed. Entered text: " + textField1.text); } }
Uncomment the above code to see the problem.
-
@DanCA-A Wrong, TextField has that signal in QuickControls 2:
https://doc.qt.io/qt-5/qml-qtquick-controls2-textfield.html
https://doc.qt.io/qt-5/qml-qtquick-controls2-textfield-members.html
https://doc.qt.io/qt-5/qml-qtquick-textinput.html#editingFinished-signal -
Looks like an unfortunate bug in the property/signal revisioning system. Could you report at bugreports.qt.io?
-
Here's one possible workaround:
Connections { target: textField1 onEditingFinished: { console.log("Editing finished text: " + textField1.text); } }
@jpnurmi Thank you for your time. I've reported the issue as QTBUG-59908.