We are using QtQuick.Controls 2.2 and can't downgrade due to various reasons. When we use Combobox
util from QML, it doesn't appear with selectByMouse
field which was introduced in 1.4 version.
Our requirement is -- to be able to select the text in the combobox for copying purpose as well as have a dropdown menu.
How to fix this issue; Is there any alternative?
You can just alter the contentItem
to be a TextField
of with the properties of your choice. This might look like this:
ComboBox {
id: control
model: ['Hallo', 'Hello', 'Sallut', 'Godan Dagin']
editable: true
contentItem: TextField {
text: control.editText
selectByMouse: true
}
}
Note that, if you edit the text, and editText
is not an element of your model, it will not be accepted to be the displayText
.
This works for QtQuick.Controls 2.2
onwards, as the properties editable
and editText
need to exist. Then it will automatically copy the edited text back to displayText
once it is a valid input.
For earlier versions, this is much harder to achieve.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With