[Qt-interest] Hide rather than quit on close window event

Aaron Lewis the.warl0ck.1989 at gmail.com
Thu Oct 28 14:05:21 CEST 2010


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Bonsoir André !

tried to call it before my custom widget is constructed and showed.

 app.setQuitOnLastWindowClosed(false);
// app is an instance of QApplication

Yeah , it still runs , but my sys tray disappears ?

Here comes my situation:

On menu bar , a custom action called Exit(X) is mapped to a slot , which
will force close my application.

if user pressed key combination or clicked on close button ( on my KDE
should be one of kwin's bar icon , not quiet sure how to call this ) , i
hide() my window.

if user triggered menu events , say it Exit(X) action , force close
everything.

First thought would be a simple modification on keyPressEvent , checking
for special events , so i checked QShortCut as Gopalakrishna
 recommened , got some inspiration so i tried:

switch ( event->key() ) {
	case Qt::ALT + Qt::Key_F4:
		hide();
		break;
}

Not working as well.

Haven't tried QShortCut yet , that would be my last help i guess ;-)

- -- 
Best Regards,
Aaron Lewis - PGP: 0xDFE6C29E
Key Server: http://keyserver.veridis.com
Finger Print: 9482 448F C7C3 896C 1DFE 7DD3 2492 A7D0 DFE6 C29E
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.16 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iQIcBAEBAgAGBQJMyWcBAAoJECSSp9Df5sKe/AkP/ik1CmqGwimKAwYzjEVlbqYt
e/evnv9Q9LZHHQ2kU1A38GqpGAPze7hCHM6Xjkfhf+vV4vgy+bH/cUr71LsnQdhl
n9eSwjivQeOPNM2JlrWVe8AKvLlLWFbD4ngGuLc/hI2mL6DnbXKIP3ZaGhxZ68sY
AsNPopQVtOWrzRwcVrjCCV2GTgSaNAHA72y9d1rMUGjUqgOCiEB6Cn9x/OVCIP3a
9NDX9jf9+jh7Fe7VjAio0fO34FMvVakfaAq9NFwvIK7lSOkuruTyPi3SEJhi6rkv
TV7JwvZNxyHBVQhTTQ4iZK4R4MzuyeNaJbLKuS5wfy9qHpfq5LVdYG3vrVmFAApW
/eV46xOGfIOjhoaxpb49Z+/+fgKv3ig2xqH/Ss2bucXvcr91FrsDWGBf7lVnhofQ
oq3gYkCalfZFGFser3YDVxIDNcp8gIDVQcBY/XLPf4lION1PVW0AjMoTyEUwiF+Z
C7c06bHAigdF5bW00Y/Q+mdAD07iFOBMYd3IQaSgJSz0Mrt9oEuzovqk7Ve9UD9B
PBwAnbXoL2HfATc4VdeTvBtZECu5DolijMJDT1oC9BIShbMW5TyDIQIL00+QSNTw
gzBasuv3V5CdFRTtWbN3vDA3nS3Hbt/8XRWOMtb6mhogDam785grt9Wb3UwmGkJH
EmETPqe/9hCp88W8NhT1
=FS+W
-----END PGP SIGNATURE-----



More information about the Qt-interest-old mailing list