QComboBox with multiple lines of text

  • I am trying to make a QCombobox which would have multiple lines of text in the format of a title and a description. This seems to me to be something which would be a common requirement and should be simple to implement but I cant find a simple example or method to do this.

    I am planning on looking into using a delegate to do this but I'm wondering if anyone has any better ideas or examples of this being done before?

  • Or possibly rather than using a delegate I should just create a new class with QComboBox as the base class and override the paintEvent to draw the description text?

  • Lifetime Qt Champion


    AFAIK, the delegate is the right thing to do in this case.

    As for your other question, I haven't seen very often a combo box with several lines worth of text for an entry. It would not necessarily make it nice to read/use.

  • @SGaist In this case the combobox has a minimum size which makes it easily readable. The layout would also only be a title and a one line (possibly even only a few words) description so it should really just be two lines.
    I'll update with my solution when completed. I've parked this for the moment as its not vital to the project.

Log in to reply

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.