Results 1 to 9 of 9

Thread: QTextBrowser and html <input> tag

  1. #1
    Join Date
    Apr 2012
    Posts
    43
    Thanks
    4
    Thanked 1 Time in 1 Post

    Default QTextBrowser and html <input> tag

    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

  2. #2
    Join Date
    Apr 2012
    Posts
    43
    Thanks
    4
    Thanked 1 Time in 1 Post

    Default Re: QTextBrowser and html <input> tag

    Anyone?

  3. #3
    Join Date
    Apr 2012
    Posts
    43
    Thanks
    4
    Thanked 1 Time in 1 Post

    Default Re: QTextBrowser and html <input> tag

    No one?

  4. #4
    Join Date
    Apr 2012
    Posts
    43
    Thanks
    4
    Thanked 1 Time in 1 Post

    Default Re: QTextBrowser and html <input> tag

    At least if it is somehow possible or if I have to find another solution?

  5. #5
    Join Date
    Apr 2012
    Posts
    43
    Thanks
    4
    Thanked 1 Time in 1 Post

    Default Re: QTextBrowser and html <input> tag

    Ok, one last try... Is there anyone who can give me at least somehow useful information? I'd be very grateful. Thanks

  6. #6
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: QTextBrowser and html <input> tag

    You can implement your own QTextObject and place it in the document where you need it. See the Text Object example for more info.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  7. The following user says thank you to wysota for this useful post:

    Raadush (24th September 2012)

  8. #7
    Join Date
    Apr 2012
    Posts
    43
    Thanks
    4
    Thanked 1 Time in 1 Post

    Default Re: QTextBrowser and html <input> tag

    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:

    Qt Code:
    1. <html>
    2. <body>
    3. <table>
    4. <tr>
    5. <td>Some text: </td>
    6. <td><input type="text"></input></td>
    7. </tr>
    8. </table>
    9. </body>
    10. </html>
    To copy to clipboard, switch view to plain text mode 

    and I display all html pages from my resources using:

    Qt Code:
    1. QString page = this->readHtml("test");
    2. QTextBrowser infoHtml;
    3. infoHtml.setText(page);
    To copy to clipboard, switch view to plain text mode 

    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?

  9. #8
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: QTextBrowser and html <input> tag

    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.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  10. The following user says thank you to wysota for this useful post:

    Raadush (24th September 2012)

  11. #9
    Join Date
    Apr 2012
    Posts
    43
    Thanks
    4
    Thanked 1 Time in 1 Post

    Default Re: QTextBrowser and html <input> tag

    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.

Similar Threads

  1. QTextBrowser html file showing problem
    By Furkan in forum Qt Programming
    Replies: 2
    Last Post: 28th February 2011, 10:42
  2. QTextBrowser and html
    By iamjayanth in forum Newbie
    Replies: 2
    Last Post: 6th July 2009, 16:49
  3. GIF or MNG images for use in html for QTextBrowser
    By manojmka in forum Qt Programming
    Replies: 3
    Last Post: 2nd January 2008, 17:30
  4. Loading images in html in a QTextBrowser
    By BasicPoke in forum Newbie
    Replies: 1
    Last Post: 6th June 2007, 22:51
  5. QTextBrowser, html & pictures
    By jey in forum Qt Programming
    Replies: 3
    Last Post: 20th March 2006, 08:43

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.