You are not logged in.

Dear visitor, welcome to QtForum.org. If this is your first visit here, please read the Help. It explains in detail how this page works. To use all features of this page, you should consider registering. Please use the registration form, to register here or read more information about the registration process. If you are already registered, please login here.

MasterBLB

Intermediate

  • "MasterBLB" is male
  • "MasterBLB" started this thread

Posts: 188

Location: Poland/Wrocław

  • Send private message

1

Sunday, May 24th 2009, 7:33pm

How to prevent closing of a window by Alt+F4[SOLVED]

Elo Brothers

As in topic-I need to make closing my window by alt+f4 unaviable,but I do not how.
I've found something like that:

Source code

1
void QWidget::releaseShortcut ( int id )

But I do not know the id,moreover I didin't found anything inside class QWidget to obtain that id :/
So I ask you Brothers for help-maybe you know a solution...?
There are 10 kinds of people.Those who do understand the binary code,and those who do not ;)

This post has been edited 1 times, last edit by "MasterBLB" (May 26th 2009, 6:21pm)


2

Monday, May 25th 2009, 3:16pm

I think the solution is the keypress function. You need to somehow capture the keypress "alt+F4" combination and disable it
Look at this :
http://doc.trolltech.com/4.5/qwidget.html#keyPressEvent

3

Monday, May 25th 2009, 3:24pm

reimplement void QWidget::closeEvent( QCloseEvent * event )

eg:

Source code

1
2
3
4
5
6
7
8
9
10
11
void YourClass::closeEvent( QCloseEvent * event )
{
	if( ! readyToClose() )
	{
		event->ignore();
	}
	else
	{
		event->accept();
	}
}

MasterBLB

Intermediate

  • "MasterBLB" is male
  • "MasterBLB" started this thread

Posts: 188

Location: Poland/Wrocław

  • Send private message

4

Tuesday, May 26th 2009, 6:21pm

I unnecesary tried to found the solution using some system mechanic,while a simple trick of reimplementing closeEvent() works fine...Thanks Brother Nicolas :)
There are 10 kinds of people.Those who do understand the binary code,and those who do not ;)