Results 1 to 7 of 7

Thread: MSG not defined (winEvent)

  1. #1
    Join Date
    Sep 2006
    Posts
    68
    Thanks
    15
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Angry MSG not defined (winEvent)

    Hi All,

    I am trying to make my program hide (leaving only the icon tray) when a user clicks the minimize. I first tried the resizeEvent, but it seems this doesn't get called when the window is Minimized.

    Searching the forum found mentions of winEvent and tried that in my header file:

    Qt Code:
    1. protected:
    2. bool winEvent( MSG * );
    To copy to clipboard, switch view to plain text mode 

    .. but when I try and compile, I always get

    Qt Code:
    1. error: ‘MSG’ has not been declared
    To copy to clipboard, switch view to plain text mode 

    I can't find it in any headers.. what do I need to include to get that to work?

    Thanks in advance.

  2. #2
    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: MSG not defined (winEvent)

    You can override QWidget::changeEvent() and catch QEvent::WindowStateChange. The event will be sent whenever the window's state (minimized, maximized or full-screen) has changed.
    J-P Nurmi

  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: MSG not defined (winEvent)

    I just realized you are using Qt3. The event type (QEvent::WindowStateChange) is the same for Qt3, but there is no changeEvent() so override QWidget::event() instead.
    J-P Nurmi

  4. #4
    Join Date
    Sep 2006
    Posts
    68
    Thanks
    15
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: MSG not defined (winEvent)

    Hi Jpn,

    I tied that.. but now just about everything has stopped working.. I tried returning both true and false, but still the main UI doesn't seem to draw, the close buttons etc don't work.

  5. #5
    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: MSG not defined (winEvent)

    Quote Originally Posted by December View Post
    I tied that.. but now just about everything has stopped working.. I tried returning both true and false, but still the main UI doesn't seem to draw, the close buttons etc don't work.
    The event must be passed to the base class implementation so that the event gets further delivered to the correct specialized event handler. For example:
    Qt Code:
    1. bool MyWidget::event(QEvent* e)
    2. {
    3. if (e->type() == QEvent::WindowStateChange)
    4. {
    5. // minimized, maximized or fullscreen state changed, do something..
    6. }
    7. return QWidget::event(e); // <-- important
    8. }
    To copy to clipboard, switch view to plain text mode 
    J-P Nurmi

  6. The following user says thank you to jpn for this useful post:

    December (19th February 2007)

  7. #6
    Join Date
    Sep 2006
    Posts
    68
    Thanks
    15
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: MSG not defined (winEvent)

    That was it.. thanks loads

    I had just about figure out that I could do it using an Event filter.. which is the better approach?

  8. #7
    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: MSG not defined (winEvent)

    Quote Originally Posted by December View Post
    I had just about figure out that I could do it using an Event filter.. which is the better approach?
    Sure, both ways work. It's just a matter of taste. Overriding an event handler in most cases results into a cleaner solution than installing an event filter. Installing an event filter might save you from subclassing but the functionality ends up into a "wrong" class..
    J-P Nurmi

Similar Threads

  1. how to corss compile for windows in Linux
    By safknw in forum Qt Programming
    Replies: 24
    Last Post: 13th May 2006, 06:23
  2. is it possible to stay on a user defined infinite loop?
    By mahe2310 in forum Qt Programming
    Replies: 9
    Last Post: 24th March 2006, 15:29
  3. Replies: 25
    Last Post: 15th January 2006, 01:53

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.