Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

QT - multi-select

I would like to create a search-type text field in QT that can contain both standard text as well as what I would call "tags"... basically additional search terms that are individually highlighted and separated. I envision this looking like the multi-select in "Chosen" (Javascript library). http://harvesthq.github.com/chosen/

I have been unable to find anything similar through searching. It also seems that the standard QT text box types are not designed to have "sub-widgets".

It appears that QTextEdit supports HTML... that might be a possiblity... but the docs are not very clear to me as what is supported in terms of CSS (which I think would be required to get the desired formatting). http://doc.qt.io/qt-5/qtextedit.html#html-prop

Its funny... I got to the bottom of this submission page and realized I have to tag this (this is my first SO question)... This tag-adder box is almost exactly what I want!

like image 852
Daniel Placek Avatar asked Dec 02 '11 06:12

Daniel Placek


1 Answers

There is no ready-to-use soultion that I know. If I were to try implementing it, I would definitely use widget with layout, in which there are two types of child widgets: LineEdits (borderless to look like actual part of bigger widget) and buttons - code managing line edit changes would simply add new buttons before or after and if necesary splited linedit into tw with button between. This way is not interfering with qt programers intentions on how to use widgets and how to make them all fit together in one style.

If you want you can use custom widgets instead of buttons to provide remove icon. As I wrote in my comment - if i have a bit more time I will try to make something like that myself.

like image 199
j_kubik Avatar answered Sep 26 '22 08:09

j_kubik