1

When I instantiate an QWebPage object I have a segmentation fault, I don't understand why !

I call my object in main.cpp

webview *nav = new webview();

my webview.h :

#ifndef WEBVIEW_H
#define WEBVIEW_H

#include <QRegularExpression>
#include <QWebPage>
#include <QWebFrame>
#include <QPrinter>
#include <QDebug>

#include "arguments.h"

class webview
{
public:
    webview();
    ~webview();
    bool load(Arguments *args);
    QWebFrame* getFrame() { return frame;}

private:
    QWebPage *page;
    QWebFrame *frame;
};

and my webview.cpp

#include "webview.h"
webview::webview()
{

    page = new QWebPage();
}
[...]
webview::~webview()
{
delete page;
}

An Segmentation fault error appear in webview constructor :

page = new QWebPage();

Really I don't understand why

you can download the project here : http://www.partage-facile.com/Y8NROQ09HG/htmltopdf.tar.gz.html

Nymeria
  • 267
  • 4
  • 13

2 Answers2

3

You cannot use QtWebKit with QCoreApplication, change all QCoreApplication to QApplication.

fxam
  • 3,874
  • 1
  • 22
  • 32
0

if you really don't need to embed you page in a Widget (you don't set the parent of it) you can create the QWebPage on the stack.

See the example in Qt docs

Massimo Costa
  • 1,864
  • 15
  • 23