Results 1 to 11 of 11

Thread: QComboBox with custom model clears text in its lineEdit

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Sep 2021
    Posts
    6
    Thanks
    2
    Thanked 1 Time in 1 Post
    Qt products
    Qt5
    Platforms
    Windows

    Question QComboBox with custom model clears text in its lineEdit

    I encountered very strange issue when implemented QComboBox with custom model (QAbstractListModel subclass). I noticed that sometimes after getting lineEdit's editingFinished signal the combox's currentText() is empty and lineEdit()->isModified() returns false. After investigating this issue I discovered that this somehow connected to custom subclass model I use. If to comment out setModel installed for the QComboBox, this problem is not observed. Moreover, this problem happens only when editing is completed with Enter pressed. If the editsimply loses focus after editing, all work as expected.
    I use Qt v5.9.8. Do you have any suggestion?

  2. #2
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    5,102
    Thanks
    289
    Thanked 844 Times in 831 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: QComboBox with custom model clears text in its lineEdit

    You should probably look at your model's setData() implementation. My guess is that when the user edits the combobox, this method is called. You may not be calling the methods needed (beginWhatever / endWhatever) to signal the combobox to update its contents and set the current index.
    Last edited by d_stranz; 20th September 2021 at 17:43.
    <=== The Great Pumpkin says ===>
    Please use CODE tags when posting source code so it is more readable. Click "Go Advanced" and then the "#" icon to insert the tags. Paste your code between them.

  3. The following user says thank you to d_stranz for this useful post:

    redsoft (23rd September 2021)

Similar Threads

  1. Replies: 1
    Last Post: 20th May 2015, 11:21
  2. QTableView line edit clears the text on edit
    By PlasticJesus in forum Qt Programming
    Replies: 5
    Last Post: 14th March 2015, 19:06
  3. Replies: 7
    Last Post: 5th February 2014, 11:20
  4. Keypress never fired on lineedit qcombobox
    By stef13013 in forum Qt Programming
    Replies: 0
    Last Post: 6th August 2012, 16:46
  5. Custom LineEdit - need help!
    By ArlexBee-871RBO in forum Qt Programming
    Replies: 8
    Last Post: 15th September 2010, 17:10

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.