inline QFlags operator&(Enum f) const { QFlags g; g.i = i & f; return g; }
> QtGuid4.dll!QFlags<enum Qt::WindowType>::operator&(Qt::WindowType f=WindowType_Mask) Line 2004 + 0x16 bytes C++ QtGuid4.dll!QWidget::windowType() Line 890 + 0x20 bytes C++ QtGuid4.dll!QApplication::desktop() Line 3041 + 0x14 bytes C++ QtGuid4.dll!QMenuPrivate::calcActionRects(QMap<QAction *,QRect> & actionRects=[0](), QList<QAction *> & actionList=[0]()) Line 209 + 0x9 bytes C++ QtGuid4.dll!QMenuPrivate::updateActions() Line 329 C++ QtGuid4.dll!QMenu::popup(const QPoint & p={...}, QAction * atAction=0x00000000) Line 1790 C++ QtGuid4.dll!QSystemTrayIconSys::winEvent(tagMSG * m=0x0012dd38, long * result=0x0012dd5c) Line 473 C++ QtGuid4.dll!QtWndProc(HWND__ * hwnd=0x00170b4e, unsigned int message=32869, unsigned int wParam=0, long lParam=517) Line 1662 + 0x18 bytes C++ user32.dll!77d38709() [Frames below may be incorrect and/or missing, no symbols loaded for user32.dll] user32.dll!77d387eb() msvcr90d.dll!_unlock(int locknum=2010351624) Line 376 C user32.dll!77d60494() user32.dll!77d39385() user32.dll!77d393df() QtCored4.dll!winPeekMessage(tagMSG * msg=0x0012dfc4, HWND__ * hWnd=0x00000000, unsigned int wMsgFilterMin=0, unsigned int wMsgFilterMax=0, unsigned int wRemoveMsg=1) Line 390 + 0x24 bytes C++ QtCored4.dll!QEventDispatcherWin32::processEvents(QFlags<enum QEventLoop::ProcessEventsFlag> flags={...}) Line 700 + 0x14 bytes C++ QtGuid4.dll!QGuiEventDispatcherWin32::processEvents(QFlags<enum QEventLoop::ProcessEventsFlag> flags={...}) Line 1182 + 0x15 bytes C++ QtCored4.dll!QEventLoop::processEvents(QFlags<enum QEventLoop::ProcessEventsFlag> flags={...}) Line 150 C++ QtCored4.dll!QEventLoop::exec(QFlags<enum QEventLoop::ProcessEventsFlag> flags={...}) Line 200 + 0x2d bytes C++ QtCored4.dll!QCoreApplication::exec() Line 880 + 0x15 bytes C++ QtGuid4.dll!QApplication::exec() Line 3554 C++ MyPro.exe!main(int argc=1, char * * argv=0x003a83e8) Line 17 + 0x6 bytes C++ MyPro.exe!WinMain(HINSTANCE__ * instance=0x00400000, HINSTANCE__ * prevInstance=0x00000000, char * __formal=0x00151f0a, int cmdShow=1) Line 136 + 0x12 bytes C++ MyPro.exe!__tmainCRTStartup() Line 574 + 0x35 bytes C MyPro.exe!WinMainCRTStartup() Line 399 C kernel32.dll!7c816d4f() kernel32.dll!7c8399f3()
#include <QtGui/QApplication>#include "mainwindow.h"#include <QDesktopWidget>int main(int argc, char *argv[]){ QApplication a(argc, argv); QDesktopWidget *scr = QApplication::desktop(); int scrWidth = scr->screen(0)->width(); int scrHeight = scr->screen(0)->height(); MainWindow Window(scrWidth, scrHeight); delete scr; return a.exec();}
#ifndef MAINWINDOW_H#define MAINWINDOW_H#include "ui_MainWindow.h"#include <QMessageBox>#include <QSystemTrayIcon>#include <QSettings>class MainWindow : public QMainWindow, public Ui::MainWindow{ Q_OBJECTprivate: int scrWidth; int scrHeight; QAction showAction; QAction hideAction; QSystemTrayIcon* Tray; QMenu TrayMenu; QSettings* settings;protected: void closeEvent(QCloseEvent *event);public: MainWindow(int deskWidth, int deskHeight, QMainWindow* pwgt = 0);public slots: void ShowMainWindowSlot(); void iconActivated(QSystemTrayIcon::ActivationReason reason); void CreateMenu(); void CreateTray(); void QuitSlot();};#endif // MAINWINDOW_H
#include "MainWindow.h"#include <QCloseEvent>#include <QMenu>//----------------------------------------------------------------------------------MainWindow::MainWindow(int deskWidth, int deskHeight,QMainWindow* pwgt): QMainWindow(pwgt), scrWidth(deskWidth), scrHeight(deskHeight), showAction(tr("Show Main Window"), this), hideAction(tr("Hide Main Window"), this){ setupUi(this); CreateMenu(); CreateTray(); connect(Tray, SIGNAL(activated(QSystemTrayIcon::ActivationReason)), SLOT(iconActivated(QSystemTrayIcon::ActivationReason))); statusbar->showMessage(tr("Welcome to MyPro!")); this->show();}//----------------------------------------------------------------------------------//----------------------------------EVENTS------------------------------------------//----------------------------------------------------------------------------------void MainWindow::closeEvent(QCloseEvent *event) { TrayMenu.removeAction(&hideAction); TrayMenu.removeAction(actionQuit); TrayMenu.addAction(&showAction); TrayMenu.addAction(actionQuit); Tray->setContextMenu(&TrayMenu); hide(); event->ignore(); }//----------------------------------------------------------------------------------//----------------------------------SLOTS-------------------------------------------//----------------------------------------------------------------------------------void MainWindow::ShowMainWindowSlot(){ TrayMenu.removeAction(&showAction); TrayMenu.removeAction(actionQuit); TrayMenu.addAction(&hideAction); TrayMenu.addAction(actionQuit); Tray->setContextMenu(&TrayMenu); show();}//-----------------------------------------------------------------------------------void MainWindow::iconActivated(QSystemTrayIcon::ActivationReason reason){ switch (reason) { case QSystemTrayIcon::Trigger: { if (this->isHidden()) this->ShowMainWindowSlot(); else this->close(); } break; default: ; }}//----------------------------------------------------------------------------------void MainWindow::CreateMenu(){ actionConnect->setStatusTip(tr("Click to connect")); actionDisconnect->setStatusTip(tr("Click to disconnect")); actionSettings->setStatusTip(tr("Click to settings")); connect(actionQuit, SIGNAL(triggered()), SLOT(QuitSlot())); actionQuit->setStatusTip(tr("Click to quit")); actionHelp->setStatusTip(tr("Click to read help")); actionUpdate->setStatusTip(tr("Click to update")); connect(actionAbout_Us, SIGNAL(triggered()), SLOT(AboutSlot())); actionAbout_Us->setStatusTip(tr("Click to read information about us"));}//----------------------------------------------------------------------------------void MainWindow::CreateTray(){ Tray = new QSystemTrayIcon(); connect(&showAction, SIGNAL(triggered()), this, SLOT(ShowMainWindowSlot())); connect(&hideAction, SIGNAL(triggered()), this, SLOT(close())); TrayMenu.addAction(&hideAction); TrayMenu.addAction(actionQuit); Tray->setContextMenu(&TrayMenu); Tray->setToolTip("MyPro"); Tray->show();}//----------------------------------------------------------------------------------void MainWindow::QuitSlot(){ Tray->hide(); qApp->quit();}//----------------------------------------------------------------------------------
<?xml version="1.0" encoding="UTF-8"?><ui version="4.0"> <class>MainWindow</class> <widget class="QMainWindow" name="MainWindow"> <property name="enabled"> <bool>true</bool> </property> <property name="geometry"> <rect> <x>0</x> <y>0</y> <width>800</width> <height>600</height> </rect> </property> <property name="sizePolicy"> <sizepolicy hsizetype="Expanding" vsizetype="Expanding"> <horstretch>0</horstretch> <verstretch>0</verstretch> </sizepolicy> </property> <property name="minimumSize"> <size> <width>190</width> <height>220</height> </size> </property> <property name="windowTitle"> <string>MainWindow</string> </property> <property name="windowIcon"> <iconset> <normaloff>../images/UmProIcon.png</normaloff>../images/UmProIcon.png</iconset> </property> <property name="locale"> <locale language="English" country="UnitedStates"/> </property> <widget class="QWidget" name="widget"> <property name="enabled"> <bool>true</bool> </property> <layout class="QGridLayout" name="gridLayout"/> </widget> <widget class="QMenuBar" name="menubar"> <property name="geometry"> <rect> <x>0</x> <y>0</y> <width>800</width> <height>19</height> </rect> </property> <property name="defaultUp"> <bool>false</bool> </property> <widget class="QMenu" name="menuMenu"> <property name="locale"> <locale language="English" country="UnitedStates"/> </property> <property name="title"> <string>Menu</string> </property> <property name="separatorsCollapsible"> <bool>true</bool> </property> <addaction name="actionConnect"/> <addaction name="actionDisconnect"/> <addaction name="separator"/> <addaction name="separator"/> <addaction name="separator"/> <addaction name="actionSettings"/> <addaction name="separator"/> <addaction name="actionQuit"/> </widget> <widget class="QMenu" name="menuHelp"> <property name="locale"> <locale language="English" country="UnitedStates"/> </property> <property name="title"> <string>Help</string> </property> <addaction name="actionHelp"/> <addaction name="separator"/> <addaction name="actionUpdate"/> <addaction name="actionAbout_Us"/> </widget> <addaction name="menuMenu"/> <addaction name="menuHelp"/> </widget> <widget class="QStatusBar" name="statusbar"> <property name="autoFillBackground"> <bool>false</bool> </property> </widget> <action name="actionConnect"> <property name="text"> <string>Connect...</string> </property> <property name="shortcut"> <string>Ctrl+C</string> </property> <property name="iconVisibleInMenu"> <bool>true</bool> </property> </action> <action name="actionDisconnect"> <property name="text"> <string>Disconnect...</string> </property> <property name="shortcut"> <string>Ctrl+D</string> </property> </action> <action name="actionEditLists"> <property name="text"> <string>Edit Lists...</string> </property> <property name="shortcut"> <string>Ctrl+E</string> </property> </action> <action name="actionAbout_Us"> <property name="text"> <string>About Us...</string> </property> </action> <action name="actionUpdate"> <property name="text"> <string>Update</string> </property> </action> <action name="actionChange_Password"> <property name="text"> <string>Change Password...</string> </property> <property name="shortcut"> <string>Ctrl+P</string> </property> </action> <action name="actionQuit"> <property name="text"> <string>Quit</string> </property> <property name="iconText"> <string>Quit</string> </property> <property name="shortcut"> <string>Ctrl+Q</string> </property> </action> <action name="actionHelp"> <property name="text"> <string>Help</string> </property> <property name="shortcut"> <string>F1</string> </property> </action> <action name="actionSettings"> <property name="text"> <string>Settings...</string> </property> <property name="shortcut"> <string>Ctrl+S</string> </property> </action> </widget> <resources/> <connections/></ui>
C++ (Qt)delete scr;