Line edit for QListWidgetItem?
-
Hi, is there a way I could get the
QLineEdit
forQListWidgetItem
when it is being edited?
For example, for aQComboBox
I can get theQLineEdit
(if theQComboBox
is editable) like this:ui.comboBox->lineEdit()
. -
@CJha said in Line edit for QListWidgetItem?:
Can I somehow get the display of QVariant data?
OK, found out that it actually does show a
QLineEdit
widget, but only for editing...
You could try a custom (QLineEdit
style) itemDelegate and set your wanted behavior there. Dunno if it will work.Edit:
Yeah, that's probably it.
Set a itemDelegate and use aQLineEdit
with someQValidator
or whatever you need, to validate your input... -
@Pl45m4 Thanks! No, you got it right.
The item itself is the "display" for QVariant data...
Can I somehow get the display of QVariant data? I just want to monitor as the user updates the text and change the color to red in case the user inputs a text that already exists. I cannot do that by changing the foreground of the item itself when the user is updating the text.
-
@CJha said in Line edit for QListWidgetItem?:
Can I somehow get the display of QVariant data?
OK, found out that it actually does show a
QLineEdit
widget, but only for editing...
You could try a custom (QLineEdit
style) itemDelegate and set your wanted behavior there. Dunno if it will work.Edit:
Yeah, that's probably it.
Set a itemDelegate and use aQLineEdit
with someQValidator
or whatever you need, to validate your input... -
- https://stackoverflow.com/questions/26614678/validating-user-input-in-a-qtableview
(will work for every model/view, I think)
Here you go :)
- https://stackoverflow.com/questions/26614678/validating-user-input-in-a-qtableview
6/6