C++ (Qt)//...int main( int argc, char ** argv ){ QApplication app( argc, argv ); Form1 *mf = new Form1(); app.setMainWidget(mf); QPopupMenu *menu = new QPopupMenu(); menu->insertItem( QObject::tr("Hide"),mf , SLOT(hide()) ); menu->insertItem( QObject::tr("Show"), mf, SLOT(show()) ); menu->insertSeparator(); menu->insertItem( QObject::tr("&Quit"), mf, SLOT(close()) ); TrayIcon *tray = new TrayIcon( QPixmap::fromMimeSource( "icon.png" ), QObject::tr("Tray"), menu); tray->show(); SLOT(mf->show())); QObject::connect(tray,SIGNAL(clicked(const QPoint&)),mf,SLOT(showNormal())); mf->hide(); return app.exec();}
Form1::closeEvent(QCloseEvent * e){ tray->show();}Form1::showEvent(QShowEvent * e){ tray->hide();}
int main( int argv, char ** argv ){ QApplication app( argc, argv ); app.setQuitOnLastWindowClosed( false ); QWidget parent; QWidget * my_widget = new QWidget( &parent, Qt::Window ); my_widget->show(); return app.exec();}
C++ (Qt)Window::closeEvent(QCloseEvent * e){if (!isClose){this->hide();e->reject();}elsee->accept();}
C++ (Qt)Window::slotExit(){isClose=true;this->close();}