Results 1 to 13 of 13

Thread: QT4/QP Tray Icon

  1. #1
    Join Date
    Jan 2006
    Location
    Grenoble, France
    Posts
    165
    Thanks
    106
    Qt products
    Qt4
    Platforms
    Windows

    Default QT4/QP Tray Icon

    I have looked through the docs but cannot find a way to minimize my application.
    I would like to minimize it not to the taskbar but to the minimized icons at the far end right of the icon list.

    Can someone point me to a spot in the docs or post a code snipet ?

  2. #2
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: QT4/QP Tray Icon

    J-P Nurmi

  3. The following user says thank you to jpn for this useful post:

    incapacitant (9th April 2006)

  4. #3
    Join Date
    Jan 2006
    Location
    Grenoble, France
    Posts
    165
    Thanks
    106
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: QT4/QP Tray Icon

    As I don't have an unarchiver for gz2, I chose the second link.
    But the file qpopmenu. is missing, looks like an old Qt include file.
    Any idea where I can find it ? Thanks

    Edit: QPopMenu is QT3, is there a replacement for QT4 ? Assistant says nothing
    Last edited by incapacitant; 9th April 2006 at 16:47.

  5. #4
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: QT4/QP Tray Icon

    Quote Originally Posted by incapacitant
    As I don't have an unarchiver for gz2, I chose the second link.
    For example WinRAR can handle tar.bz2's. The second example is for Qt 3.
    J-P Nurmi

  6. #5
    Join Date
    Mar 2006
    Posts
    172
    Thanks
    30
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Lightbulb Re: QT4/QP Tray Icon

    Well jpn, thanks for the pointer to the example.....Now what I'd like to know is that is it possible to reverse the above process....I.e. read the contents of the system tray and display them in another widget? (esp on X11)

    Thanks

    Nupul

  7. #6
    Join Date
    Jan 2006
    Location
    Grenoble, France
    Posts
    165
    Thanks
    106
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: QT4/QP Tray Icon

    I have some trouble understanding the is Qt4 code :
    - the main directory has no main.cpp
    - can't really understand how to use the class if it is supposed to be one ?
    - can you explain a bit what's the functional principle, i don' t understand the code ?
    EDIT: what pro files corresponds to the pri file ?
    EDIT2: i created pro file for the directory exemple which also has a copy of the mainwindow.* and application.* files, the linker says :
    Thanks
    Qt Code:
    1. C:\Qt\test\trayicon\example\trayicon.o(.text+0x780) In function `ZN8TrayIconD2Ev':
    2. [Linker error] undefined reference to `TrayIcon::sysRemove()'
    To copy to clipboard, switch view to plain text mode 

    Some code is missing ? the function sysRemove is in a class as such : just called.
    Last edited by incapacitant; 15th April 2006 at 16:09.

  8. #7
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: QT4/QP Tray Icon

    There should be enough information in files README.TXT and trayicon.cpp for get ting started..
    Attached Files Attached Files
    J-P Nurmi

  9. The following user says thank you to jpn for this useful post:

    incapacitant (19th April 2006)

  10. #8
    Join Date
    Jan 2006
    Location
    Grenoble, France
    Posts
    165
    Thanks
    106
    Qt products
    Qt4
    Platforms
    Windows

    Default QT4/QP Tray Icon

    I managed to have the systray exampe work under qt4.1.3 but I have a problem.
    For info I took the code from a previous post example.zip by jpn.
    The minimize action is linked to the window's minimize button and I want to link it to a proper QPushButton.

    So I modified the mainwindow :
    Qt Code:
    1. MainWindow::MainWindow() : QMainWindow()
    2. {
    3. pbClose = new QPushButton( this );
    4. pbClose->resize( QSize( 10, 10 ) );
    5.  
    6. qApp->setApplicationName("ExampleApp");
    7. setupTray();
    8. }
    To copy to clipboard, switch view to plain text mode 

    So that now a button is displayed on the mainwindow.

    Then I replaced:
    Qt Code:
    1. connect(mTray, SIGNAL(clicked(const QPoint &, int)), SLOT(toggleVisibility()));
    To copy to clipboard, switch view to plain text mode 

    with:

    Qt Code:
    1. connect(pbClose, SIGNAL(clicked()), SLOT(toggleVisibility()));
    To copy to clipboard, switch view to plain text mode 

    Then when I click on the button the application is minimized but when I double-click on the icon in the taskbar it won't come back maximized. It comes back when I keep the original mTray connect.

    I tried:
    Qt Code:
    1. connect(pbClose, SIGNAL(clicked(const QPoint &, int)), SLOT(toggleVisibility()));
    To copy to clipboard, switch view to plain text mode 

    But then it is worse the button once activated does not minimize anything.
    Another weird thing is that even without the original mTray connect, the window's minimize button continues to minimize !

    To finish and even with my button connection, the QMenu works always.

  11. #9
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: QT4/QP Tray Icon

    Quote Originally Posted by incapacitant
    Then when I click on the button the application is minimized but when I double-click on the icon in the taskbar it won't come back maximized. It comes back when I keep the original mTray connect.
    Don't remove the line which connects the clicking of tray icon to view the window. Just add the button connection in addition to the other connections:
    Qt Code:
    1. connect(mTray, SIGNAL(clicked(const QPoint &, int)), SLOT(toggleVisibility())); // don't remove this!
    2. connect(pbClose, SIGNAL(clicked()), SLOT(toggleVisibility())); // just add this
    To copy to clipboard, switch view to plain text mode 

    Quote Originally Posted by incapacitant
    ..the window's minimize button continues to minimize !
    You could supply window flags indicating that there is no need for minimize or maximize buttons:
    Qt Code:
    1. MainWindow::MainWindow() : QMainWindow()
    2. {
    3. // a window with title and system menu, but no minmax buttons
    4. setWindowFlags(Qt::Window | Qt::WindowTitleHint | Qt::WindowSystemMenuHint);
    5.  
    6. mClose = new QPushButton( this );
    7. mClose->resize( QSize( 10, 10 ) );
    8.  
    9. qApp->setApplicationName("ExampleApp");
    10. setupTray();
    11. }
    To copy to clipboard, switch view to plain text mode 
    J-P Nurmi

  12. The following user says thank you to jpn for this useful post:

    incapacitant (20th May 2006)

  13. #10
    Join Date
    Jan 2006
    Location
    Grenoble, France
    Posts
    165
    Thanks
    106
    Qt products
    Qt4
    Platforms
    Windows

    Default QT4/XP Tray Icon

    jpn:

    I did both which suits me fine as far as the window's minimize button is gone but the window's close is still there. Perfect.

    Then I left both connections and my button will minimize the window.

    Now, when I double-click on the icon in the taskbar the window is remaximized and then reminimized immediately without and any action from my side. It won't stay restored.

  14. #11
    Join Date
    Jun 2006
    Posts
    2
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QT4/QP Tray Icon

    Is anyone having problems with this? I'm running gnome on FC5 and QT4, but the system tray icon only shows up as a vertical line one pixel wide . . . kinda tough to click

    *edit*
    it works perfectly in KDE, but I really need it working in Gnome (~ 2.14.0)

    help???
    Last edited by honkfrog; 7th June 2006 at 16:36. Reason: update

  15. #12
    Join Date
    Jan 2006
    Location
    South Carolina, USA
    Posts
    34
    Thanked 4 Times in 4 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QT4/QP Tray Icon

    Quote Originally Posted by honkfrog
    Is anyone having problems with this? I'm running gnome on FC5 and QT4, but the system tray icon only shows up as a vertical line one pixel wide . . . kinda tough to click

    *edit*
    it works perfectly in KDE, but I really need it working in Gnome (~ 2.14.0)

    help???
    But KDE is so much better..

    Ok, honestly I don't know the answer. I just couldn't resist the comment. Hopefully someone does though...

  16. #13
    Join Date
    Jun 2006
    Posts
    2
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QT4/QP Tray Icon

    I set WMDock to true, and when it runs, I get a new widget with a scrambled picture that works like a system tray icon . . . If that helps with any diagnosis.

    This happens with the exact example code, only I've put in a png file as the pixmap

Similar Threads

  1. How to write some text next to the system tray icon?
    By alex chpenst in forum Qt Programming
    Replies: 3
    Last Post: 5th September 2008, 08:43
  2. possible to convert string/numbers to tray icon?
    By jarmok in forum Qt Programming
    Replies: 2
    Last Post: 19th July 2008, 18:34
  3. Replies: 4
    Last Post: 30th June 2008, 06:25
  4. Mac application and the Dock Icon
    By sekelsenmat in forum Qt Programming
    Replies: 3
    Last Post: 26th September 2007, 10:23
  5. Tray Icon
    By vishesh in forum Qt Programming
    Replies: 1
    Last Post: 12th July 2007, 19:10

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.