CloseEvent gives invalid use or incomplete 'struct QCloseEvent'



  • 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



  • You're just missing the corresponding #include. :-)



  • Thank you Peppe. I am a newbie, kindly asking, can you please elaborate. #include what ? and put where ?

    Many thanks Peppe



  • Ahhhhhhhhhhh got it :) many thanks Peppe



  • @
    #include <QCloseEvent>
    @
    at the top of your implementation file should do it.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.