PDA

View Full Version : QTextBrowser and html <input> tag



Raadush
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?

Thanks

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

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

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

Raadush
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

wysota
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.

Raadush
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:



<html>
<body>
<table>
<tr>
<td>Some text: </td>
<td><input type="text"></input></td>
</tr>
</table>
</body>
</html>


and I display all html pages from my resources using:



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


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?

wysota
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.

Raadush
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. :)