Got the app hiding in the system tray, though icon isn't working.
When you hit the close button on the window, it hides in the system tray, or when you hit File>Hide or Ctrl+H while the application has focus. I have some testing code in to see why the icon isn't being set, but still can't figure it out. The icon is definitely loading, it's just when I set it to the icon it's no visible. I'm even not getting console output saying no icon is being set.
This commit is contained in:
parent
003c8a1157
commit
c7914480e0
6 changed files with 124 additions and 36 deletions
|
@ -2,21 +2,43 @@
|
|||
#define MAINWINDOW_H
|
||||
|
||||
#include <QMainWindow>
|
||||
#include <QSystemTrayIcon>
|
||||
|
||||
namespace Ui {
|
||||
class MainWindow;
|
||||
}
|
||||
|
||||
///
|
||||
// http://qt-project.org/doc/qt-4.8/desktop-systray.html
|
||||
///
|
||||
class MainWindow : public QMainWindow
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
typedef QMainWindow BaseType;
|
||||
|
||||
public:
|
||||
explicit MainWindow(QWidget *parent = 0);
|
||||
~MainWindow();
|
||||
|
||||
public slots:
|
||||
void save();
|
||||
void exit();
|
||||
|
||||
void iconActivated(QSystemTrayIcon::ActivationReason reason);
|
||||
|
||||
private:
|
||||
Ui::MainWindow *ui;
|
||||
|
||||
QSystemTrayIcon* m_pTrayIcon;
|
||||
QMenu* m_pTrayIconMenu;
|
||||
QAction* m_pExitAction;
|
||||
QPixmap* m_pActiveIcon;
|
||||
QPixmap* m_pInactiveIcon;
|
||||
|
||||
virtual void closeEvent(QCloseEvent* event);
|
||||
virtual void hideEvent(QHideEvent* event);
|
||||
virtual void showEvent(QShowEvent* event);
|
||||
};
|
||||
|
||||
#endif // MAINWINDOW_H
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue