Results 1 to 2 of 2

Thread: CloseEvent gives invalid use or incomplete 'struct QCloseEvent'

  1. #1
    Join Date
    Jul 2011
    Posts
    16
    Thanks
    8
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default 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
    Qt Code:
    1. #ifndef FULLSCREENDIAL_H
    2. #define FULLSCREENDIAL_H
    3.  
    4. #include <QDialog>
    5.  
    6. namespace Ui {
    7. class fullScreenDial;
    8. }
    9.  
    10. class fullScreenDial : public QDialog
    11. {
    12. Q_OBJECT
    13.  
    14. public:
    15. explicit fullScreenDial(QWidget *parent = 0);
    16. ~fullScreenDial();
    17.  
    18. private:
    19. Ui::fullScreenDial *ui;
    20.  
    21. protected:
    22. void closeEvent(QCloseEvent *);
    23. void reject();
    24. };
    25.  
    26. #endif // FULLSCREENDIAL_H
    To copy to clipboard, switch view to plain text mode 

    fullscreendial.cpp

    Qt Code:
    1. #include "fullscreendial.h"
    2. #include "ui_fullscreendial.h"
    3.  
    4. fullScreenDial::fullScreenDial(QWidget *parent) :
    5. QDialog(parent),
    6. ui(new Ui::fullScreenDial)
    7. {
    8. ui->setupUi(this);
    9.  
    10.  
    11. // int x=1;
    12. }
    13.  
    14. fullScreenDial::~fullScreenDial()
    15. {
    16. delete ui;
    17. }
    18.  
    19. void fullScreenDial::closeEvent( QCloseEvent * event) {
    20.  
    21.  
    22. event->ignore();
    23. }
    24.  
    25. void fullScreenDial::reject()
    26. {
    27. }
    To copy to clipboard, switch view to plain text mode 

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

    Many thanks

  2. #2
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: CloseEvent gives invalid use or incomplete 'struct QCloseEvent'

    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:
    Qt Code:
    1. // In your header file
    2. #include <QCloseEvent>
    3.  
    4. OR
    5. // in your header
    6. // and in your cpp file
    7. #include <QCloseEvent>
    To copy to clipboard, switch view to plain text mode 

  3. The following user says thank you to ChrisW67 for this useful post:

    nackasha (30th October 2011)

Similar Threads

  1. invalid use of incomplete type 'struct MSG'
    By libed in forum Qt Programming
    Replies: 5
    Last Post: 21st February 2019, 12:32
  2. QSql - incomplete type 'struct QVariant'
    By UltramaticOrange in forum Newbie
    Replies: 2
    Last Post: 5th October 2010, 19:07
  3. error: invalid use of incomplete type 'struct QMetaEnum'
    By dyngoman in forum Qt Programming
    Replies: 3
    Last Post: 12th March 2010, 13:38
  4. Replies: 4
    Last Post: 12th October 2009, 19:36
  5. Forward Declaration of struct QCloseEvent ????
    By drake1983 in forum Newbie
    Replies: 2
    Last Post: 3rd February 2009, 15:16

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.