QWebPage segmentation fault

拈花ヽ惹草 提交于 2019-12-11 08:08:54

问题


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


回答1:


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




回答2:


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



来源:https://stackoverflow.com/questions/25119520/qwebpage-segmentation-fault

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!