truefusion
23rd February 2009, 10:37
I know where the problem is, but i have no idea how to fix it. The problem is located in websubwindow.cpp: when it tries to access the child widgets it segfaults, starting at the first vbox->addWidget().
The file structure is:
torah.cpp
torah.h
gui/websubwindow.cpp
gui/websubwindow.h
websubwindow.cpp
#include "websubwindow.h"
webSubWindow::webSubWindow(QWidget * parent, Qt::WindowFlags flags)
: QMdiSubWindow(parent, flags)
{
setWindowTitle(tr("Personal"));
setAttribute(Qt::WA_DeleteOnClose);
vbox->addWidget(addressLine);
vbox->addWidget(progressBar);
vbox->addWidget(webView);
vbox->addWidget(statusBar);
centralWidget->setLayout(vbox);
progressBar->setHidden(true);
addressLine->setEditText("http://");
setWidget(centralWidget);
connect(addressLine, SIGNAL(activated(const QString &)), this, SLOT(goToUrl(const QString &)));
//connect(addressLine->lineEdit(), SIGNAL(returnPressed()), this, SLOT(goToUrl()));
}
webSubWindow::~webSubWindow()
{
delete centralWidget;
delete vbox;
delete addressLine;
delete progressBar;
delete webView;
delete url;
}
websubwindow.h
#ifndef WEBSUBWINDOW_H
#define WEBSUBWINDOW_H
#include <QtGui/QMdiSubWindow>
#include <QtGui/QWidget>
#include <QtGui/QVBoxLayout>
#include <QtGui/QComboBox>
#include <QtGui/QProgressBar>
#include <QtGui/QStatusBar>
#include <QtCore/QUrl>
#include <QtWebKit/QWebView>
class webSubWindow : public QMdiSubWindow
{
Q_OBJECT
private:
QWidget *centralWidget;
QVBoxLayout *vbox;
QUrl *url;
public:
webSubWindow(QWidget * parent = 0, Qt::WindowFlags flags = 0);
~webSubWindow();
QComboBox *addressLine;
QProgressBar *progressBar;
QWebView *webView;
QStatusBar *statusBar;
private slots:
void goToUrl(const QString &url);
};
#endif // WEBSUBWINDOW_H
torah.cpp
#include "torah.h"
#include "ui_torah.h"
#include "gui/websubwindow.h"
Torah::Torah(QWidget *parent)
: QMainWindow(parent), ui(new Ui::TorahClass)
{
ui->setupUi(this);
ui->action_Refresh->setVisible(false);
ui->action_Stop->setVisible(false);
ui->action_Back->setEnabled(false);
ui->action_Forward->setEnabled(false);
connect(ui->actionNew_Tab, SIGNAL(triggered()), this, SLOT(addTab()));
}
Torah::~Torah()
{
delete ui;
}
void Torah::addTab()
{
webSubWindow *child = new webSubWindow;
//QMdiSubWindow *child = new QMdiSubWindow;
ui->mdiArea->addSubWindow(child);
child->show();
}
torah.h
#ifndef TORAH_H
#define TORAH_H
#include <QtGui/QMainWindow>
namespace Ui
{
class TorahClass;
}
class Torah : public QMainWindow
{
Q_OBJECT
public:
Torah(QWidget *parent = 0);
~Torah();
private:
Ui::TorahClass *ui;
private slots:
void addTab();
};
#endif // TORAH_H
Any help is appreciated; i've been trying many things to try and solve the problem, but i'm getting no where.
The file structure is:
torah.cpp
torah.h
gui/websubwindow.cpp
gui/websubwindow.h
websubwindow.cpp
#include "websubwindow.h"
webSubWindow::webSubWindow(QWidget * parent, Qt::WindowFlags flags)
: QMdiSubWindow(parent, flags)
{
setWindowTitle(tr("Personal"));
setAttribute(Qt::WA_DeleteOnClose);
vbox->addWidget(addressLine);
vbox->addWidget(progressBar);
vbox->addWidget(webView);
vbox->addWidget(statusBar);
centralWidget->setLayout(vbox);
progressBar->setHidden(true);
addressLine->setEditText("http://");
setWidget(centralWidget);
connect(addressLine, SIGNAL(activated(const QString &)), this, SLOT(goToUrl(const QString &)));
//connect(addressLine->lineEdit(), SIGNAL(returnPressed()), this, SLOT(goToUrl()));
}
webSubWindow::~webSubWindow()
{
delete centralWidget;
delete vbox;
delete addressLine;
delete progressBar;
delete webView;
delete url;
}
websubwindow.h
#ifndef WEBSUBWINDOW_H
#define WEBSUBWINDOW_H
#include <QtGui/QMdiSubWindow>
#include <QtGui/QWidget>
#include <QtGui/QVBoxLayout>
#include <QtGui/QComboBox>
#include <QtGui/QProgressBar>
#include <QtGui/QStatusBar>
#include <QtCore/QUrl>
#include <QtWebKit/QWebView>
class webSubWindow : public QMdiSubWindow
{
Q_OBJECT
private:
QWidget *centralWidget;
QVBoxLayout *vbox;
QUrl *url;
public:
webSubWindow(QWidget * parent = 0, Qt::WindowFlags flags = 0);
~webSubWindow();
QComboBox *addressLine;
QProgressBar *progressBar;
QWebView *webView;
QStatusBar *statusBar;
private slots:
void goToUrl(const QString &url);
};
#endif // WEBSUBWINDOW_H
torah.cpp
#include "torah.h"
#include "ui_torah.h"
#include "gui/websubwindow.h"
Torah::Torah(QWidget *parent)
: QMainWindow(parent), ui(new Ui::TorahClass)
{
ui->setupUi(this);
ui->action_Refresh->setVisible(false);
ui->action_Stop->setVisible(false);
ui->action_Back->setEnabled(false);
ui->action_Forward->setEnabled(false);
connect(ui->actionNew_Tab, SIGNAL(triggered()), this, SLOT(addTab()));
}
Torah::~Torah()
{
delete ui;
}
void Torah::addTab()
{
webSubWindow *child = new webSubWindow;
//QMdiSubWindow *child = new QMdiSubWindow;
ui->mdiArea->addSubWindow(child);
child->show();
}
torah.h
#ifndef TORAH_H
#define TORAH_H
#include <QtGui/QMainWindow>
namespace Ui
{
class TorahClass;
}
class Torah : public QMainWindow
{
Q_OBJECT
public:
Torah(QWidget *parent = 0);
~Torah();
private:
Ui::TorahClass *ui;
private slots:
void addTab();
};
#endif // TORAH_H
Any help is appreciated; i've been trying many things to try and solve the problem, but i'm getting no where.