Important: Please read the Qt Code of Conduct -

QComboBox - How to get RichText in QLineEdit

  • Hello,
    i have a editable combo box, the edit-field is for search-inputs, the drop down list is needed to reach lasts inputs easily.
    If the user inputs regular expressions, i want to highlight the special characters of that expressions like ".+*" etc.
    Is there an easy way to use rich edit formatting in the edit field of a QComboBox?
    Or can I replace the QLineEdit by (a one line) QTextEdit?

    If not, my plan is to display a QTextEdit and reduce the QComboBox to the popuplist-button and expand the popuplist.
    But do not prefer this,
    If the answer is, that i have to subclass QComboBox and override painting, is there a way to use rich edit formatting easily?

    Thank you

  • Moderators

    QLineEdit officially doesn't support rich text via it's public API.
    But internally it does support it! You can only set the formatting, but not retrieve it again.

    This is the only way i am aware of which makes it possible to set the formatting.

    p.s. replacing the line edit widget of a combobox isn't possible.

Log in to reply