hi
i am using qtwebkit
i have two forms .the first is my main window and have a push button . in slot clicked of it i want to show my second form and using webview show a url (just as a simple test) but webview does not show the url . what is wrong ?
here is my code :
my main window header :
#ifndef MAINWINDOW_H
#define MAINWINDOW_H
#include <qmainwindow>
namespace Ui {
class MainWindow;
}
class MainWindow : public QMainWindow
{
Q_OBJECT
public:
explicit MainWindow(QWidget *parent = 0);
~MainWindow();
private:
Ui::MainWindow *ui;
private slots:
void on_pushButton_pressed();
};
#endif // MAINWINDOW_H
</qmainwindow>
my main window source file :
#include "mainwindow.h"
#include "ui_mainwindow.h"
#include "webview.h"
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
ui->setupUi(this);
}
MainWindow::~MainWindow()
{
delete ui;
}
void MainWindow::on_pushButton_pressed()
{
webview *w = new webview();
w->show();
w->setURL(QUrl("www.google.com"));
}
my webview header file :
#ifndef WEBVIEW_H
#define WEBVIEW_H
#include <qmainwindow>
#include <qurl>
namespace Ui {
class webview;
}
class webview : public QMainWindow
{
Q_OBJECT
public:
explicit webview(QWidget *parent = 0);
~webview();
void setURL(const QUrl&);
private:
Ui::webview *ui;
};
#endif // WEBVIEW_H
</qurl></qmainwindow>
my webview source file :
#include "webview.h"
#include "ui_webview.h"
#include <qmessagebox>
webview::webview(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::webview)
{
ui->setupUi(this);
}
webview::~webview()
{
delete ui;
}
void webview::setURL(const QUrl& url)
{
QMessageBox::information(0,"1","2");
ui->webView->load(url);
}
</qmessagebox>
and my main file :
#include
#include "mainwindow.h"
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
MainWindow w;
w.show();
return a.exec();
}