PDA

View Full Version : Window title bar and "X" button



markcole
19th December 2007, 16:40
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...

marcel
20th December 2007, 15:18
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().

markcole
20th December 2007, 21:44
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.

marcel
20th December 2007, 21:58
You marcel are a genius.

Thanks, but I'm not, really... :)