Results 1 to 4 of 4

Thread: Window title bar and "X" button

  1. #1
    Join Date
    Apr 2007
    Posts
    23
    Thanks
    6
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Window title bar and "X" button

    Is there a way to differentiate between the close() issues by the "X" button and a call to close() from outside the widget?

    What I want is a window with a border and title bar, but not allow the window to be closed by the user. I have tried changing the window flags, but I cannot seem to get a combination were the is a border with no X.

    Any suggstions either way?

    I am using SUSE 10.1 and QT4.2

    Thanks...

  2. #2
    Join Date
    Feb 2006
    Location
    Romania
    Posts
    2,744
    Thanks
    8
    Thanked 541 Times in 521 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Window title bar and "X" button

    Although there's no direct way to tell that, you can use QEvent::spontaneous() to see if the event came from outside the app. Since the title bar is being managed by the platform window manager it seems logical that a QCloseEvent issued by pressing the close button will be spontaneous. If my assumption is true then you can figure out how to use the value of QEvent::spontaneous().

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

    markcole (20th December 2007)

  4. #3
    Join Date
    Apr 2007
    Posts
    23
    Thanks
    6
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Window title bar and "X" button

    Quote Originally Posted by marcel View Post
    Although there's no direct way to tell that, you can use QEvent::spontaneous() to see if the event came from outside the app. Since the title bar is being managed by the platform window manager it seems logical that a QCloseEvent issued by pressing the close button will be spontaneous. If my assumption is true then you can figure out how to use the value of QEvent::spontaneous().
    You marcel are a genius. clicking the "X" returned true and a call to close() from the creating runtime returned false.

    I would never have tried to use that.

  5. #4
    Join Date
    Feb 2006
    Location
    Romania
    Posts
    2,744
    Thanks
    8
    Thanked 541 Times in 521 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Window title bar and "X" button

    You marcel are a genius.
    Thanks, but I'm not, really...

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.