Results 1 to 3 of 3

Thread: QTrayIcon shown on the left. Why? how can i fix this?

  1. #1
    Join Date
    Jul 2010
    Location
    /home/hakermania/
    Posts
    233
    Thanks
    129
    Thanked 3 Times in 3 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Question QTrayIcon shown on the left. Why? how can i fix this?

    This is on the constructor:
    Qt Code:
    1. trayIcon = new QSystemTrayIcon(this);
    2. trayIcon->setIcon(QIcon(":/icons/omg4.png"));
    3. trayIcon->setToolTip("Wallpaper Changer \nDouble click to show the window.\nMiddle click to exit the application.\nRight click for some options.");
    4. connect(trayIcon,SIGNAL(activated(QSystemTrayIcon::ActivationReason)),this,SLOT(clickSysTrayIcon(QSystemTrayIcon::ActivationReason)));
    5. connect(this,SIGNAL(minimized()),this,SLOT(hide()),Qt::QueuedConnection);
    6. QMenu *clock_menu = new QMenu;
    7. //clock_menu->addAction("&Play",this,SLOT(playClicked()));
    8. //clock_menu->addAction("P&ause",this,SLOT(pauseClicked()));
    9. //clock_menu->addAction("St&op",this,SLOT(stopClicked()));
    10. clock_menu->addAction("&Show",this,SLOT(showClicked()));
    11. clock_menu->addAction("Se&ttings",this,SLOT(showSettings()));
    12. clock_menu->addAction(QIcon(":/new/clock/clock.png"),"&About",this,SLOT(showAbout()));
    13. clock_menu->addSeparator();
    14. clock_menu->addAction("&Exit",qApp,SLOT(quit()));
    15. trayIcon->setContextMenu(clock_menu);
    To copy to clipboard, switch view to plain text mode 
    This on the change event:
    Qt Code:
    1. switch (e->type()) {
    2. case QEvent::LanguageChange:
    3. ui->retranslateUi(this);
    4. break;
    5.  
    6. //see if the event is changing the window state
    7. case QEvent::WindowStateChange:
    8. //if it is, we need to see that this event is minimize
    9.  
    10. if (isMinimized()) {
    11. //EDWWWWWWWW
    12. trayIcon->show();
    13. // QCoreApplication::sendPostedEvents(QObject *trayIcon);
    14. enum MessageIcon { NoIcon, Information, Warning, Critical };
    15. QSystemTrayIcon::MessageIcon icon = QSystemTrayIcon::MessageIcon(Information);
    16.  
    17. trayIcon->showMessage("titlos", "mplampla", icon, 10000);
    18. emit minimized();}
    19.  
    20. default:
    21. break;
    22.  
    23. QMainWindow::changeEvent(e); }
    To copy to clipboard, switch view to plain text mode 
    And this is the void function while it is minimized:
    Qt Code:
    1. void MainWindow::clickSysTrayIcon(QSystemTrayIcon::ActivationReason reason)
    2. {
    3. //reason is a variable that holds the type of activation or click done on the icon tray
    4. switch (reason) {
    5. case QSystemTrayIcon::DoubleClick: //if it's a double click
    6. //hide the icon
    7. trayIcon->hide();
    8. //show the main window
    9. this->showNormal();
    10. break;
    11. case QSystemTrayIcon::MiddleClick:
    12. //quit the application
    13. qApp->quit();
    14. break;
    15. case QSystemTrayIcon::Unknown:
    16. break;
    17. case QSystemTrayIcon::Context:
    18. break;
    19. case QSystemTrayIcon::Trigger:
    20. break;
    21. default :
    22. ;
    23. }
    24. }
    To copy to clipboard, switch view to plain text mode 
    I don't know why but the message is shown on the left and not below the application's icon. Why is this happening and how can I fix it?

  2. #2
    Join Date
    Aug 2010
    Posts
    107
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QTrayIcon shown on the left. Why? how can i fix this?

    I have the same problem... Anybody?

  3. #3
    Join Date
    Aug 2010
    Posts
    107
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QTrayIcon shown on the left. Why? how can i fix this?

    Can anybody answer why is this happening? And how can be fixed?

Similar Threads

  1. Replies: 4
    Last Post: 29th August 2010, 18:16
  2. Dialog Update before shown
    By winder in forum Qt Programming
    Replies: 3
    Last Post: 27th February 2010, 18:50
  3. How to set which axis are shown?
    By Jeo_ in forum Qwt
    Replies: 1
    Last Post: 28th April 2009, 14:05
  4. Allow Many QWidgets to be Shown into One QWidget ?
    By Fatla in forum Qt Programming
    Replies: 26
    Last Post: 6th July 2008, 09:29
  5. Progress Bar to be shown!!!
    By Kapil in forum Qt Programming
    Replies: 7
    Last Post: 23rd May 2006, 09:36

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.