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;
}
{
Q_OBJECT
public:
~Widget();
protected:
private:
Ui::WidgetClass *ui;
};
#endif // 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
To copy to clipboard, switch view to plain text mode
and this my widget.cpp
#include "widget.h"
#include "ui_widget.h"
: QWidget(parent
), ui
(new Ui
::WidgetClass) {
ui->setupUi(this);
}
Widget::~Widget()
{
delete ui;
}
{
event->ignore();
}
#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();
}
To copy to clipboard, switch view to plain text mode
Any help?
Thanks!!!
Bookmarks