Results 1 to 2 of 2

Thread: Unable to handle WindowStateChange events

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jun 2006
    Location
    Sweden
    Posts
    99
    Thanks
    11
    Thanked 3 Times in 3 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Question Unable to handle WindowStateChange events

    Hi there!

    I'm sitting on linux and find myself needing to keep the user from changing the window state of a dialog. To start off with, i tried setting the window flags such that no minimize or maximize buttons would be shown. This failed since for some reason, my window manager insists on drawing at least a maximize button and depending on my system settings, a 'shade' button as well.

    My next stop was to accept the minimize or maximize buttons being shown, but ignore the WindowStateChange events. So i implemented QDialog::changeEvent(QEvent*) in hopes of being able to ignore the appropriate events as they come in:

    Qt Code:
    1. void MyDialog::changeEvent(QEvent* event)
    2. {
    3. if (event->type() == QEvent::WindowStateChange){
    4. cout << "window state change event! window state:" << windowState() << endl;
    5. //should i perhaps do event->accept() or event->ignore() here?
    6. }else{
    7. QDialog::changeEvent(event);
    8. }
    9.  
    10. }
    To copy to clipboard, switch view to plain text mode 

    Unfortunately, this doesn't work either. The events are still getting through and the window is still being minimized and maximized. Am i completely at the mercy of the window manager or is there some way, any way, of solving this problem!?

    thanks in advance!

  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: Unable to handle WindowStateChange events

    You can tell the dialog to remain fixed in size, for instance using QLayout::sizeConstraint property.

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

    TheRonin (6th March 2008)

Similar Threads

  1. QPushButton:: Handle right mouse button events. Easyway?
    By Harvey West in forum Qt Programming
    Replies: 6
    Last Post: 28th February 2007, 16:56
  2. Replies: 17
    Last Post: 8th February 2007, 16:30

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.