PDA

View Full Version : Forward Declaration of struct QCloseEvent ????



drake1983
3rd February 2009, 06:07
Hi everybody!!!
I have a problem using QCloseEvent inside a Widget .When I'm try to compile my program I get two errors:
- invalid use of incomplete type 'struct QCloseEvent'
- forward declaration of 'struct QCloseEvent'

I have read the Qt4 Doc about closeEvent but I can find the problem.


This is my widget.h


#ifndef WIDGET_H
#define WIDGET_H

#include <QtGui/QWidget>

namespace Ui
{
class WidgetClass;
}

class Widget : public QWidget
{
Q_OBJECT

public:
Widget(QWidget *parent = 0);
~Widget();

protected:
void closeEvent( QCloseEvent *event);
private:
Ui::WidgetClass *ui;
};

#endif // WIDGET_H



and this my widget.cpp


#include "widget.h"
#include "ui_widget.h"

Widget::Widget(QWidget *parent)
: QWidget(parent), ui(new Ui::WidgetClass)
{
ui->setupUi(this);
}

Widget::~Widget()
{
delete ui;
}

void Widget::closeEvent(QCloseEvent *event)
{
event->ignore();
}



Any help?
Thanks!!!:o

spirit
3rd February 2009, 06:27
try this


class QCloseEvent;//forward declaration

class Widget : public QWidget
{
....
};
....
#include <QCloseEvent>
#include "widget.h"
#include "ui_widget.h"

Widget::Widget(QWidget *parent)
....

drake1983
3rd February 2009, 15:16
Thanks a lot!!! it works!!!