Results 1 to 6 of 6

Thread: How to show Multiple Message using QSystemTrayIcon?

  1. #1
    Join Date
    Aug 2007
    Location
    Gorakhpur, India
    Posts
    254
    Thanks
    8
    Thanked 14 Times in 14 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Question How to show Multiple Message using QSystemTrayIcon?

    Qt Code:
    1. foreach (QString str, msgData) {
    2. QSystemTrayIcon::MessageIcon icon = QSystemTrayIcon::MessageIcon();
    3. this->showMessage(tr("Alert"), str, icon);
    4. sleep(2);
    5. }
    To copy to clipboard, switch view to plain text mode 
    The above code doesn't display all the message. Only the last alert is visible. How to display all the alerts.
    Anurag Shukla
    A man who never makes mistake is the man who never does anything! Theodre Rosvelt!

  2. #2
    Join Date
    Jul 2006
    Location
    Catalunya - Spain
    Posts
    117
    Thanks
    16
    Thanked 8 Times in 8 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: How to show Multiple Message using QSystemTrayIcon?

    Try adding this line of code ( not tested, but I think it must do the work... )
    Quote Originally Posted by ashukla View Post
    Qt Code:
    1. foreach (QString str, msgData) {
    2. QSystemTrayIcon::MessageIcon icon = QSystemTrayIcon::MessageIcon();
    3. this->showMessage(tr("Alert"), str, icon);
    4. QCoreApplication::processEvents(); // <= THIS LINE
    5. sleep(2);
    6. }
    To copy to clipboard, switch view to plain text mode 

  3. #3
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    4,380
    Thanks
    19
    Thanked 1,005 Times in 913 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60
    Wiki edits
    5

    Default Re: How to show Multiple Message using QSystemTrayIcon?

    Quote Originally Posted by ashukla View Post
    Qt Code:
    1. sleep(2);
    To copy to clipboard, switch view to plain text mode 
    Wow, that will block your whole application! Better use a QTimer.

  4. #4
    Join Date
    Aug 2007
    Location
    Gorakhpur, India
    Posts
    254
    Thanks
    8
    Thanked 14 Times in 14 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Default Re: How to show Multiple Message using QSystemTrayIcon?

    Qt Code:
    1. foreach (QString str, msgData) {
    2. QSystemTrayIcon::MessageIcon icon = QSystemTrayIcon::MessageIcon();
    3. this->showMessage(tr("Alert"), str, icon);
    4. QCoreApplication::processEvents(); // <= THIS LINE
    5. sleep(2);
    6. }
    To copy to clipboard, switch view to plain text mode 
    the output is same as previous.
    Anurag Shukla
    A man who never makes mistake is the man who never does anything! Theodre Rosvelt!

  5. #5
    Join Date
    Aug 2007
    Location
    Gorakhpur, India
    Posts
    254
    Thanks
    8
    Thanked 14 Times in 14 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Default Re: How to show Multiple Message using QSystemTrayIcon?

    Quote Originally Posted by Lykurg View Post
    Wow, that will block your whole application! Better use a QTimer.
    Where I put this timer?
    Anurag Shukla
    A man who never makes mistake is the man who never does anything! Theodre Rosvelt!

  6. #6
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    4,380
    Thanks
    19
    Thanked 1,005 Times in 913 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60
    Wiki edits
    5

    Default Re: How to show Multiple Message using QSystemTrayIcon?

    Quote Originally Posted by ashukla View Post
    the output is same as previous.
    because of your sleep(). First it is only possible to display one message. So if you have more you must place them with time elapse.

    • Store all messages in a QQueue.
    • call a showMyMessages(): if the queue in not empty and the timer is not running display the message and start a timer which calls the same function again in X seconds. if no message are left stop timer.

Similar Threads

  1. Replies: 1
    Last Post: 16th April 2009, 16:12
  2. Replies: 4
    Last Post: 12th October 2008, 13:47
  3. Replies: 7
    Last Post: 14th March 2008, 13:52
  4. StatusBar show message
    By Pang in forum Qt Programming
    Replies: 3
    Last Post: 23rd August 2007, 10:22
  5. QSystemTrayIcon doesn't show icon ?
    By probine in forum Qt Programming
    Replies: 3
    Last Post: 25th January 2007, 19:17

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.