How to insert a combobox to QTextTable cell or QTextEdit?

  • I'd like to add a combobox into my QTextEdit content, which just needs to provide options for user to pick and record the selected one. I tried to insert the following as HTML to QTextEdit, but it does not work.

    <form name=myform>
    <select name=mytextarea>
    <option name=one value=one> one </option>
    <option name=two value=two> two </option>
    <option name=three value=three> three </option>

  • Lifetime Qt Champion


    QTextEdit is not a full featured web renderer. For what you want to do you should rather consider either QtWebEngine or QtWebKit.

  • How easy it is to convert QTextEdit to QtWebEngine etc? I'm using QTextEdit as a rich text editor and I have gone quite far with it. Since it is like an editor, it to deal with dynamically adding/deleting table/image/text etc, can QtWebEngine do that? I read some introduction about QtWebEngine and it is more like an engine to display html content... Any suggestion? Thanks.

    For the combobox in QTextEdit, I do not need any signal etc. The combobox just need to show the text user select and that is it. Is there a way to achieve this in QTextEdit?

  • Lifetime Qt Champion

    You should check with for example the Markdown Editor example.

    As for the combobox, I'm not aware of that possibility however, I don't know how it is supposed to work within your editor. You could maybe use a contextual menu for that or have a QComboBox has an overlay on your document when your user should make a choice.

  • context menu does the trick. Thank you very much.

Log in to reply