View Full Version : QTextBrowser and html <input> tag

14th September 2012, 15:11
Hi, simple question. Is there some way to display for example html <input type="text"> inside QTextBrowser and retrieve text from it? I can't afford to use QWebView because my whole app is designed for QTextBrowser and also mainly because i can't have dependency on qwebkit. If not, is there some workaround solving this problem?


17th September 2012, 08:24
Anyone? :confused:

18th September 2012, 10:41
No one? :crying:

19th September 2012, 11:51
At least if it is somehow possible or if I have to find another solution?

24th September 2012, 08:45
Ok, one last try... Is there anyone who can give me at least somehow useful information? I'd be very grateful. Thanks

24th September 2012, 08:46
You can implement your own QTextObject and place it in the document where you need it. See the Text Object example for more info.

24th September 2012, 09:53
Thanks for your tip. It seem like this might work. Still Im little confused about how to do it. Lets say I have simple page test.htm:

<td>Some text: </td>
<td><input type="text"></input></td>

and I display all html pages from my resources using:

QString page = this->readHtml("test");
QTextBrowser infoHtml;

Where readHtml is my method used for loading specific pages from resource file based on it's name specified as parameter. In this example (as I said), input tag is not working. Can you please give me some more hints how to trnasform this using QTextObject?

24th September 2012, 10:26
You need to do it in a way similar to the insertTextObject() method in the example. Qt's rich text parser will not do that automatically for you. I think it'd be easiest if you changed your <input> tag to something the parser will not strip out (e.g. "::input::"), then once QTextBrowser is done doing its job, find all occurences of that marker and replace them with proper text objects using QTextCursor API. Note that the hard part in solving your problem is getting the events delivered to proper objects so that the form becomes editable.

24th September 2012, 10:42
Ok, thanks for your tips. Since this looks rather complicated and I need this only inside very little part of my application (so I dont want to spend much time with such a little part), I think I will solve this problem using something like QGridLayout with QLabels and QTextEdits isnide. Thanks anyways. :)