-
Bug
-
Resolution: Invalid
-
Not Evaluated
-
None
-
6.7.0 Beta1, 6.8
-
None
-
1e6cb2462 (dev), 460f8e4c3 (6.7), 5cba3f5a8 (dev), 21dfc2508 (6.7)
I think this ought to be possible:
TextArea {
textDocument.onStatusChanged: {
const statusMessages = {
TextDocument.ReadError: "Failed to load ",
TextDocument.WriteError: "Failed to save ",
TextDocument.NonLocalFileError: "Not a local file: ",
}
const err = statusMessages[textDocument.status]
if (err) {
errorDialog.text = err
errorDialog.open()
}
}
I'd go even further and put the string table into a property rather than needing to re-construct this const object each time the statusChanged callback occurs. (So what type should the property be then?) But either way, there is an error; in this case it says
texteditor.qml:500:33: Expected token `,'
I guess it doesn't expect a dot operator to occur in the key definition; whereas using a plain hard-coded number as a key is fine.
https://codereview.qt-project.org/c/qt/qtdeclarative/+/537373 tries to modify the texteditor example in this way.
| For Gerrit Dashboard: QTBUG-121946 | ||||||
|---|---|---|---|---|---|---|
| # | Subject | Branch | Project | Status | CR | V |
| 537373,6 | Use lookup table to show TextDocument status in texteditor example | dev | qt/qtdeclarative | Status: MERGED | +2 | 0 |
| 539550,2 | Use lookup table to show TextDocument status in texteditor example | 6.7 | qt/qtdeclarative | Status: MERGED | +2 | 0 |
| 539811,4 | Text editor example: fix up the touch-specific UI | dev | qt/qtdeclarative | Status: MERGED | +2 | 0 |
| 540629,2 | Text editor example: fix up the touch-specific UI | 6.7 | qt/qtdeclarative | Status: MERGED | +2 | 0 |