Results 1 to 2 of 2

Thread: Is there any way to convert a QWebView object to a QVariant object?

  1. #1
    Join Date
    Nov 2013
    Posts
    2
    Qt products
    Qt4 Qt5
    Platforms
    Windows

    Default Is there any way to convert a QWebView object to a QVariant object?

    First of all, sorry I don't have much sample code to go off of, I'm really lost on this. I'm working in Qt 4.7, and I have a UI with a TableView object. I have the data() function set up so that everything else on the table populates correctly. However, there is one cell that is giving me lots of problems. Some of the cells need to be populated with data from an html page. Most of this is fine, as I just have data() return QVariant(dataneeded.toPlainText()) for those portions. However, one part is in tags, and in the original HTML page creates a button. My project manager wants this code to create a button on the table. However, when I try to copy the code over like the others (which just require text from the webpage) it just copies the text of the html, e.g. .

    Now, as I was testing this, I had a different UI set up with a QWebView to see the results I was getting from this webpage. When I passed the same portion of the HTML into the QWebView object, it created the button, just like on the original webpage. I figured, if I could create a QWebView object, create the button within that, and return that to the proper index on the TableView object with the data() function, it would work. However, the data() function needs to return a QVariant, and I can't find any way to format it to get the QWebView through. My question is, does anyone know any way to format the result of the QWebView object to pass it as a QVariant for the data() function? Also if anyone knows any other ways that would create the button that would be great to, I'm just at a total loss. Thanks!

  2. #2
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,628
    Thanks
    13
    Thanked 1,592 Times in 1,520 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: Is there any way to convert a QWebView object to a QVariant object?

    Some options
    Have data() return the HTML not the plain text. Then in the view use a delegate to paint the HTML using Webkit.
    Have data() return a pixmap obtained by rendering the HTML with Webkit and a delegate to display the image.

Similar Threads

  1. TypeError: Object [object Object] has no method 'sendData'
    By TheIndependentAquarius in forum Qt Quick
    Replies: 2
    Last Post: 30th November 2013, 05:54
  2. Replies: 1
    Last Post: 8th November 2011, 22:27
  3. Size of object in QWebView
    By Raja Mukherji in forum Qt Programming
    Replies: 0
    Last Post: 21st March 2011, 13:24
  4. Convert QByteArray to object and vice versa
    By DiamonDogX in forum Qt Programming
    Replies: 4
    Last Post: 20th July 2009, 20:07
  5. How to convert QVariant to my custom object?
    By troorl_ua in forum Qt Programming
    Replies: 3
    Last Post: 15th July 2007, 18:59

Tags for this Thread

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.