Results 1 to 3 of 3

Thread: Forward Declaration of struct QCloseEvent ????

  1. #1
    Join Date
    Mar 2007
    Posts
    31
    Thanks
    13
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Forward Declaration of struct QCloseEvent ????

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

    and this my widget.cpp
    Qt Code:
    1. #include "widget.h"
    2. #include "ui_widget.h"
    3.  
    4. Widget::Widget(QWidget *parent)
    5. : QWidget(parent), ui(new Ui::WidgetClass)
    6. {
    7. ui->setupUi(this);
    8. }
    9.  
    10. Widget::~Widget()
    11. {
    12. delete ui;
    13. }
    14.  
    15. void Widget::closeEvent(QCloseEvent *event)
    16. {
    17. event->ignore();
    18. }
    To copy to clipboard, switch view to plain text mode 


    Any help?
    Thanks!!!
    Last edited by drake1983; 3rd February 2009 at 06:08. Reason: reformatted to look better

  2. #2
    Join Date
    Aug 2008
    Location
    Ukraine, Krivoy Rog
    Posts
    1,963
    Thanked 370 Times in 336 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Forward Declaration of struct QCloseEvent ????

    try this
    Qt Code:
    1. class QCloseEvent;//forward declaration
    2.  
    3. class Widget : public QWidget
    4. {
    5. ....
    6. };
    7. ....
    8. #include <QCloseEvent>
    9. #include "widget.h"
    10. #include "ui_widget.h"
    11.  
    12. Widget::Widget(QWidget *parent)
    13. ....
    To copy to clipboard, switch view to plain text mode 
    Qt Assistant -- rocks!
    please, use tags [CODE] & [/CODE].

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

    drake1983 (3rd February 2009)

  4. #3
    Join Date
    Mar 2007
    Posts
    31
    Thanks
    13
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Forward Declaration of struct QCloseEvent ????

    Thanks a lot!!! it works!!!

Similar Threads

  1. error: forward declaration of 'struct QPushButton'
    By prykHetQuo in forum Qt Programming
    Replies: 2
    Last Post: 23rd January 2009, 23:20
  2. Replies: 16
    Last Post: 23rd May 2008, 10:12
  3. problem with forward declaration
    By MarkoSan in forum General Programming
    Replies: 14
    Last Post: 6th January 2008, 21:45
  4. Make error with Qt Jambi 4.3.2_01
    By pamalite in forum Installation and Deployment
    Replies: 0
    Last Post: 22nd November 2007, 12:05
  5. Forward declaration with std namespace
    By Raistlin in forum General Programming
    Replies: 2
    Last Post: 5th March 2007, 20:45

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.