2

How can I create an instance of a QWebFrame? (In my case, I don't really need the QWebPage instance, a single QWebFrame would be enough.)

Albert
  • 65,406
  • 61
  • 242
  • 386

2 Answers2

0

At least in Python, QWebFrame has no init method - which basically means it has no constructor (the equivalent in Java, for example).

The developers tried to avoid creating WebFrames on their own because they have no meaning when they are stand-alone.

WebFrames should be accessed and controlled using WebPage, I'm afraid.

You can try making a single frame, and then use 'load()' on it instead of creating a new one:

myFrame = webView.page().currentFrame()
#some code here...
myFrame.load('http://dumbwaystodie.com')
Matanoga
  • 101
  • 5
-1

Like any other instance:

QWebPage page;

or

QWebPage *page = new QWebPage;

Also check Qt doc for "Using QWebPage in a Widget-less Environment" on QWebPage doc page.

hate-engine
  • 2,300
  • 18
  • 26
  • @Albert Yes, I can. QWebPage has a public constructor. Have you add #include in cpp file and QT += webkit in project file? – hate-engine Apr 19 '12 at 19:27
  • Whoops, I misread your answer. I was asking about `QWebFrame`, not `QWebPage`. I know how to create a `QWebPage` (as I said indirectly in my question). But I want to create a single `QWebFrame`. Or I just wanted to know wether that's possible or not. From all I know so far, it seems it is not possible. But I haven't really found any documentation about that. – Albert Apr 19 '12 at 22:26