Tak jsem se snažil to předělat do této podoby:
#include <iostream>
#include <QtGui>
#include <QtWebKit>
#include <QDebug>
#include <main.h>
uDebats::uDebats(): QObject()
{
}
void uDebats::LoadPage(){
webpage->load(QUrl("http://idnes.cz"));
QObject::connect (webpage , SIGNAL(loadFinished()) , SLOT(loadFinished()));
//return 0;
}
void uDebats::SavePage(){
QPrinter *printer = new QPrinter(QPrinter::HighResolution);
printer->setPageSize(QPrinter::A4);
printer->setOutputFormat(QPrinter::PdfFormat);
printer->setOutputFileName("file.pdf");
webpage->print(printer);
delete webpage;
//return 0;
}
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
uDebats neco;
neco.LoadPage();
return a.exec();
}
Hlavicka je:
#ifndef MAIN_H
#define MAIN_H
#include <QWebView>
class uDebats : public QObject
{
Q_OBJECT
public:
void LoadPage();
uDebats();
signals:
void loadFinished();
private slots:
void SavePage();
private:
QWebView *webpage;
};
#endif // MAIN_H
Problém je v tom že jak se začne volat:
uDebats neco;
neco.LoadPage();
Tak program spadne. Nevíte čím to je? Bug v Qt?