PDA

View Full Version : QT4/QP Tray Icon



incapacitant
9th April 2006, 13:54
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 ?

jpn
9th April 2006, 13:57
http://qtnode.net/wiki/Systray

incapacitant
9th April 2006, 16:40
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

jpn
9th April 2006, 16:50
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.

nupul
10th April 2006, 06:36
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

incapacitant
15th April 2006, 15:51
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


C:\Qt\test\trayicon\example\trayicon.o(.text+0x780 ) In function `ZN8TrayIconD2Ev':
[Linker error] undefined reference to `TrayIcon::sysRemove()'


Some code is missing ? the function sysRemove is in a class as such : just called.

jpn
17th April 2006, 21:12
There should be enough information in files README.TXT and trayicon.cpp for get ting started.. :)

incapacitant
20th May 2006, 13:54
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 :


MainWindow::MainWindow() : QMainWindow()
{
pbClose = new QPushButton( this );
pbClose->resize( QSize( 10, 10 ) );

qApp->setApplicationName("ExampleApp");
setupTray();
}


So that now a button is displayed on the mainwindow.

Then I replaced:


connect(mTray, SIGNAL(clicked(const QPoint &, int)), SLOT(toggleVisibility()));


with:



connect(pbClose, SIGNAL(clicked()), SLOT(toggleVisibility()));


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:


connect(pbClose, SIGNAL(clicked(const QPoint &, int)), SLOT(toggleVisibility()));


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.

jpn
20th May 2006, 14:12
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:


connect(mTray, SIGNAL(clicked(const QPoint &, int)), SLOT(toggleVisibility())); // don't remove this!
connect(pbClose, SIGNAL(clicked()), SLOT(toggleVisibility())); // just add this



..the window's minimize button continues to minimize !
You could supply window flags indicating that there is no need for minimize or maximize buttons:


MainWindow::MainWindow() : QMainWindow()
{
// a window with title and system menu, but no minmax buttons
setWindowFlags(Qt::Window | Qt::WindowTitleHint | Qt::WindowSystemMenuHint);

mClose = new QPushButton( this );
mClose->resize( QSize( 10, 10 ) );

qApp->setApplicationName("ExampleApp");
setupTray();
}

incapacitant
20th May 2006, 14:55
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.

honkfrog
7th June 2006, 16:19
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 :confused:

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

help???

michael
7th June 2006, 16:42
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 :confused:

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

help???

But KDE is so much better.. :D

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

honkfrog
7th June 2006, 18:47
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