void QWidget::activateWindow ()
void QWidget::activateWindow()
void QWidget::raise()
#ifdef Q_OS_WIN#define _WIN32_WINNT 0x0501#include <qt_windows.h>#endifint main(int argc, char* argv[]){#ifdef Q_OS_WIN AllowSetForegroundWindow(ASFW_ANY);#endif//...
void MyMainWindow::activate(){ setWindowState(windowState() & ~Qt::WindowMinimized); raise(); activateWindow();}
void MainWindow::trayIconActivated(QSystemTrayIcon::ActivationReason reason){ switch(reason) { case QSystemTrayIcon::Trigger: if(isMinimized()) { setWindowState(windowState() & ~Qt::WindowMinimized | Qt::WindowActive); } else if(!isVisible()) { show(); activateWindow(); } else { hide(); } break; case QSystemTrayIcon::DoubleClick: default: break; }}