PDA

View Full Version : CloseEvent gives invalid use or incomplete 'struct QCloseEvent'



nackasha
30th October 2011, 00:05
Hello,

I am trying to override CloseEvent but i am getting the following error

invalid use of incomplete type 'struct QCloseEvent'
forward declaration of 'struct QCloseEvent'

Here is my code:

fullscreendial.h


#ifndef FULLSCREENDIAL_H
#define FULLSCREENDIAL_H

#include <QDialog>

namespace Ui {
class fullScreenDial;
}

class fullScreenDial : public QDialog
{
Q_OBJECT

public:
explicit fullScreenDial(QWidget *parent = 0);
~fullScreenDial();

private:
Ui::fullScreenDial *ui;

protected:
void closeEvent(QCloseEvent *);
void reject();
};

#endif // FULLSCREENDIAL_H


fullscreendial.cpp


#include "fullscreendial.h"
#include "ui_fullscreendial.h"

fullScreenDial::fullScreenDial(QWidget *parent) :
QDialog(parent),
ui(new Ui::fullScreenDial)
{
ui->setupUi(this);


// int x=1;
}

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

void fullScreenDial::closeEvent( QCloseEvent * event) {


event->ignore();
}

void fullScreenDial::reject()
{
}


Can you please let me know what I am doing wrong ?

Many thanks

ChrisW67
30th October 2011, 00:44
You need to have a declaration of the QCloseEvent class in order for the compiler to compile this code (this is not a Qt problem). The quickest way is to:


// In your header file
#include <QCloseEvent>

OR
// in your header
class QCloseEvent;
// and in your cpp file
#include <QCloseEvent>