Results 1 to 3 of 3

Thread: [Qt4.5] event(QEvent * event) freeze application

  1. #1
    Join Date
    May 2009
    Posts
    9
    Qt products
    Qt4
    Platforms
    Windows

    Default [Qt4.5] event(QEvent * event) freeze application

    when I try to use event it freeze everything
    *.h
    Qt Code:
    1. #include <QtGui/QWidget>
    2.  
    3.  
    4. namespace Ui
    5. {
    6. class Widget;
    7.  
    8. }
    9. class Widget : public QWidget
    10. {
    11. Q_OBJECT
    12. protected:
    13. virtual bool event(QEvent * event);
    14. public:
    15. Widget(QWidget *parent = 0);
    16. ~Widget();
    17.  
    18. public slots:
    19.  
    20. private:
    21. Ui::Widget *ui;
    22.  
    23. };
    To copy to clipboard, switch view to plain text mode 
    *.cpp
    Qt Code:
    1. bool Widget::event(QEvent * event)
    2. {event->accept();
    3. if(event->type()==QEvent::Enter)
    4. {
    5. ui->label_2->setText("QEvent::Enter");
    6. }
    7. return true;
    8. }
    To copy to clipboard, switch view to plain text mode 

    it looks like it is working but only some miliseconds and stops. label_2 had write only half of text "QEvent::E"
    Last edited by jpn; 25th May 2009 at 20:23. Reason: changed [qtclass] to [code]

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: [Qt4.5] event(QEvent * event) freeze application

    You are returning true for any event for the widget thus no events are processed by proper event handlers (including a paint event).
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  3. #3
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: [Qt4.5] event(QEvent * event) freeze application

    Qt Code:
    1. bool Widget::event(QEvent * event)
    2. {
    3. if(event->type()==QEvent::Enter)
    4. {
    5. event->accept();
    6. ui->label_2->setText("QEvent::Enter");
    7. return true;
    8. }
    9. return QWidget::event(event);
    10. }
    To copy to clipboard, switch view to plain text mode 
    J-P Nurmi

Similar Threads

  1. Replies: 4
    Last Post: 19th February 2009, 11:10
  2. Qt4.2.2: Application freeze
    By arunvv in forum Newbie
    Replies: 1
    Last Post: 9th September 2008, 21:16
  3. Qt plug-in for GLib event loop based application
    By profoX in forum Qt Programming
    Replies: 1
    Last Post: 14th June 2008, 14:27
  4. Close Event for DialogBased Application.
    By merry in forum Qt Programming
    Replies: 1
    Last Post: 12th December 2007, 12:33
  5. How to post a key event to another application
    By mitskits in forum Qt Programming
    Replies: 1
    Last Post: 23rd June 2006, 13:09

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.