Search code examples
c++qtqwebpage

QWebPage segmentation fault


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


Solution

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